Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Generic Relationship

This should work, as long as you define the OneToMany correctly,
i.e.
      @OneToMany
      protected List<ClassA> myInstances;

or if you want a OneToOne
      @OneToOne
      protected ClassA myInstance;

What error are you getting?

In general using TABLE_PER_CLASS with relationships is not a good idea. 
Normally using SINGLE_TABLE or JOINED is better.


Charles Bedon wrote:
> 
> Hello
> 
> I'm really new to JPA, and I'm using EclipselLink as PP, but as I'm a bit
> short of time I haven't been able to dig into the documentation deep
> enough. I have these entity classes:
> 
> public abstract class ClassA{...}
> 
> 
> public  class ClassA_1 extends ClassA{...}
> 
> 
> public  class ClassA_2 extends ClassA{...}
> 
> 
> And I'd like another entity class something doing this, in order to be
> able to reference an instance of ClassA_1 or ClassA_2:
> 
> 
> public class ClassB{
>       ....
> 
> 
>       @OneToMany
>       protected ClassA myInstance;
> 
> 
>       ...
> }
> 
> 
> Is this possible? I'm currently using an awful workaround involving an
> "adapter" as a wildcard for this relationship. I'm using a table per class
> strategy. Thanks for your input!
> 
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/Generic-Relationship-tp29776432p29826100.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top