-->
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.  [ 1 post ] 
Author Message
 Post subject: Foreign constraints without associations (detached objects)
PostPosted: Tue Nov 10, 2009 2:45 pm 
Newbie

Joined: Fri Nov 06, 2009 6:17 am
Posts: 2
I had some trouble about detached objects and getting them attached again to a new session. I merged them, but the associations (objects in a set) were not updated automatically. As a result a query delivered new objects with the data instead of giving me the existing objects. Therefore I decided to do the loading by myself and instead of using associations to write the IDs and parentIDs by myself. By I had no success so far. I would like to let Hibernate generate the database and need to have the proper constraints.

My tries:
1. In the first place I tried to work with one session (single user environment). Hibernate would work only with valid (unique) references in that case. But in case an exception occurs the session is not really valid any more. So I couldn't avoid to reattach all my objects..

2. I tried to add "manually" a foreign constraint via <database-object>. But the SQL was not executed.

3. I tried <many-to-one name="parentId" column="PARENTID" class="Parent" not-null="true" />. The foreign constraint was created as I could see in the logs, but I had to make parentId of type "Parent". I couldn't use the type long for parentId, because I got some strange exceptions at saving. I would really appreciate to avoid these associations, because I know they are not valid.

Did I miss anything?

Thanks.


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

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.