-->
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.  [ 3 posts ] 
Author Message
 Post subject: Preverse a Set in hibernate
PostPosted: Wed Mar 09, 2005 3:27 pm 
Beginner
Beginner

Joined: Fri Mar 12, 2004 5:18 pm
Posts: 44
I have a Set in my class:

private String aStr;
private Set aSet = new HashSet();

And I following the hibernate in action example in saving a Set (page 212), like this:

[code]
<property name="aStr" type="string" column="a_STR" not-null="true" />

<set name="aSet" cascade="save-update" inverse="true">

<key column="SET_ID"/>
<element type="string" column="SET_STR" not-null="true"/>
</set>
[code]

When I save the class, the string 'aStr" is saved to the database, but the set is not. Can someone please tell me what did I miss?

I tried changing the "cascade" property in the mapping file, that does not help. And when I stepping thru the debugger, my "aSet" is not empty.

Thank you.

Sam
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 09, 2005 3:55 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
read all you can find (reference guide, wiki, forum, hibernate in action) about "inverse" parameter, this is really important, you must read it

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 09, 2005 4:28 pm 
Beginner
Beginner

Joined: Fri Mar 12, 2004 5:18 pm
Posts: 44
Thank you for your respond. I read the chapter 3 of "Hibernate in Action".

Now I remove the 'inverse" attribute since it is a directional relation, it still does not save the "set" of my "String" object in my class.




Any further is appreciated.

Sam


Code:

<set name="selection" cascade="all-delete-orphan" lazy="true"
         access="rss.DirectSetAccessor">



         <key column="SELECTION_ID" />

         <element type="string" column="SELECTION_STR"
            not-null="true" />

      </set>


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