-->
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.  [ 6 posts ] 
Author Message
 Post subject: Set with elements of type PersistentEnum
PostPosted: Thu Jan 22, 2004 11:03 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:06 am
Posts: 21
Location: Denmark
I want to do a mapping like:

<set name="myEnums">
<key column="parent_id"/>
<element type="com.foo.MyEnum"/>
</set>

where MyEnum implements PersistentEnum and is modeled like the example in the ref manual.

Assuming that the rules for <composite-element> inside a collection also applies to <element> inside a collection, will I get issues when using the MyEnum class in different sets in different classes due to sharing of the MyEnum instances?? (the instances actually used are singletons defined inside the MyEnum class itself and therefore shared between all sets)..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 11:26 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Not as far as I am aware.
Hibernate will resolve the object reference to the singleton instance using static fromInt() provided by you, in your class implementing the PersistentEnum interface - (similar to that of the serialisation readResolve() method). Note that is method is not part of the interface as the return value is dependent on the class implementing the method.

Specifically which rules are you referring to?
Justin


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 11:31 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:06 am
Posts: 21
Location: Denmark
section 9.5 of the ref. manual states the following:
"composite elements may not own collections, and they should not be the child of any entity other than the unique parent"...

using singletons (which the PersistentEnum implementations are) means breaking the second rule.. unless "they" refers to the database rows and not the objects....


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 1:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
PersistentEnums are a value type. They are not entities. The manual uses very strict language, you should read it again.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 4:40 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:06 am
Posts: 21
Location: Denmark
right...but as far as I remember, it does not say anything about the composite elements being value types, and the quote from section 9.5 only talks about the parent being an entity. But what is the conclusion here? That composite elements are always a value type?

thanks,
Hoover


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 1:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
All components are always value types, no matter how they appear.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.