javahibernatejpanamed-queryhyperjaxb

How to add NamedQueries annotation with hyperjaxb


My question is very simple and straightforward. I need to add a @NamedQueries annotation to my generated entity classes. The JPA layer is being generated with Hyperjaxb. I do not know how to use the element to add this line

...
@NamedQueries(value = {
    @NamedQuery(name ="SampleType.sampleQuery", query="select r from SampleType r where r.index=:index"),
})
public class SampleType{
....
}

How do I add that specific annotation to the generated type?

<bindings node="xsd:complexType[@name='SampleType']">
.... // What do I put here???
</bindings>

Solution

  • I figure it out

    <bindings node="xsd:complexType[@name='SampleType']">
    <annox:annotate>
        <annox:annotate
            annox:class="org.hibernate.annotations.NamedQueries">
            <annox:annotate
                annox:class="org.hibernate.annotations.NamedQuery"
                name="SampleType.sampleQuery" query="select r from SampleType r where r.index=:index">
            </annox:annotate>
        </annox:annotate>
    </annox:annotate> 
    ....
    ....
    </bindings>