-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate/EJB and interfaces?
PostPosted: Sat Jun 11, 2005 2:01 am 
Newbie

Joined: Sat Jun 11, 2005 1:49 am
Posts: 3
Hi all,

Is anyone able to point me in the direction of more information on persisting interfaces in Hibernate/EJB3.0? I can't see them mentioned specifically in either the EJB3.0 persistance spec, or the Hibernate docs.

Hibernate talks about querying using interfaces, but I'm trying to figure out if it will support persisting fields whose types are interfaces, where the implementing class is not known a compile time.

E.g.

Code:
interface Item {}

class ItemList {

   Item someitem;
   List itemList;       /* presume these are all 'Items' */
}


Lets presume there are three or more implementations of 'Item'.... can Hibernate naturally map this to a relational schema? Maybe 1 column for each possible implementing class (some JDO implementations do this). How about collections?

Thanks for your time.

Roger


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 11, 2005 2:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Why do you think that "interface" is different from "class" from Hibernate's point of view?

(Especially when it explicitly says that there is no difference in the docs.)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 11, 2005 2:57 am 
Newbie

Joined: Sat Jun 11, 2005 1:49 am
Posts: 3
Hi Gavin,

Thanks for your reply.

So I guess the answer is 'yes'... I'm interested to know how this is implemented - can you tell me how it looks in a database schema? Are there one or more columns for someItem which reference other tables? ... and for lists?

Kind regards,

Roger


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 11, 2005 11:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Of course the Hibernate documentation covers all the ways you can map inheritance and polymorphic associations in Hibernate. Reading the docs is highly recommended.

(Perhaps you are looking for an <any> mapping. Personally I try to use <union-subclass> instead of <any>.)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.