-->
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.  [ 13 posts ] 
Author Message
 Post subject: regarding composite id and saveorupdate method
PostPosted: Tue Jul 13, 2004 4:56 pm 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
The doc says we need to implement the Interceptor.isUnsaved method in order to be able to use the saveorupdate with a persistent object having composite id as primary key. Is there any sample implementation or could someone post the sample for this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 4:57 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You can also use the unsaved-value strategy on a <version> or <timestamp> property.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 5:03 pm 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
is there an explanation on either of these implementations?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 5:03 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Yes, in the documentation.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 8:02 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Hello Christian,
Is there this features without change legacy table (add version)
I send post version and legacy database (in beginners forum) for possible solution ?

regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 8:57 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Yes, you can use <class ... optimistic-lock="all">, but this only works if you are using a single Session during the long transaction. This is a bit more complex, usually, I really recommend Hibernate in Action for this.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 9:44 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
I have Hibernate in Action - is optimistic-lock="all" use all columns in update comand ?

regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 9:47 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Exactly, in chapter 5.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 10:19 am 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
Ok,
I did exactly what's documented for implementing the Interceptor.isUnsaved method for my entity with composite id key.

http://www.hibernate.org/hib_docs/refer ... ild-update

I just call saveOrupdate for that entity and it seems still its trying to do an insert for already existing records.

Any pointers?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 10:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Check if the interceptor is actually called.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 10:32 am 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
Yes, it gets called but the call is always made for onsave of the interceptor.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 11:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Are you using 2.1.4 ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 11:36 am 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
O Initializing Hibernate
Environment I net.sf.hibernate.cfg.Environment Hibernate 2.0.3

That's my console output when hibernate is initialized.


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