[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Interface annotation?

Hi,

In toplink/eclipselink native there is this advanced feature, where you can query on an interface.

For instance if Cat and Dog both implement a common interface, say Lovable, but are mapped in different tables and don't even have a common superclass you can send a ReadAllQuery(Lovable.class) and get both cats and dogs.

Can I define this with annotations? I know it's not JPA standard, but I looked in the JPA Extensions and found VariableOneToOneMapping, which is a mapping to an interface. So I was wondering if one can annotate an interface, maybe define its query keys in the annotation, and be able to query on them. With EJBQL?


In the native project.xml it's something like this

<class-mapping-descriptor xsi:type="relational-class-mapping-descriptor">
<class>pet.Lovable</class>
..
<query-keys>
<query-key name="sweetnessFactor" xsi:type="query-key"/>
..
</query-keys> </class-mapping-descriptor>


<class-mapping-descriptor xsi:type="relational-class-mapping-descriptor">
<class>pet.Cat</class>
.. <interfaces>
<interface>pet.Lovable</interface>
</interfaces>
</class-mapping-descriptor>



Thanx,

Ana