-->
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 objects need values from db trigger while not yet
PostPosted: Wed Nov 16, 2005 10:04 am 
Newbie

Joined: Wed Nov 16, 2005 9:23 am
Posts: 2
Dear all,

I have a problem with hibernate objects which are not syncronized with the underlying database record within a running transaction.
The tricky part is, that certain fields are set in the database using an insert trigger, and I need to get these values into my hibernate business object before it is commited.

To illustrate, I have the following scenario:

{tx start by SpringHibernateTransactionManager}
-crate a new empty OrderBasket business object
-set some attributes on the OrderBasket
-call getHibernateTemplate().saveOrUpdate(orderBasket);
-call getHibernateTemplate().flush();
-call getHibernateTemplate().findByNamedQuery("OrderBask et.findByUniqueId");

here we see, that the update date is not set on the business object.

{tx commit by SpringHibernateTransactionManager}

Even if I call OrderBasket getHibernateTemplate().refresh(orderBasket), it does not help. In this case, I get an exception as follows: "could not load an entity".

Can anybody give me a hint on where I have to look into?
Thank you for any help.
Christoph


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 10:16 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Waht about evicting the object from the session after the flush and then reloading it?
The drawback of this solution is that you will get a new object reference which might be a problem.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 10:17 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
refresh()


Top
 Profile  
 
 Post subject: Tried refresh, but then i get the error: "COULD NOT LOA
PostPosted: Thu Nov 17, 2005 3:36 am 
Newbie

Joined: Wed Nov 16, 2005 9:23 am
Posts: 2
Hello Christian

I tried refresh, but then i get the error: "COULD NOT LOAD AN ENTITY".
Do you have some more idea, where I have to change someting?
Thanks a lot!


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.