-->
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: Updated bean ignore, bean retrieved prev in readonly query
PostPosted: Thu Apr 06, 2006 8:04 pm 
Newbie

Joined: Tue Feb 14, 2006 8:25 pm
Posts: 3
Environment: Container managed transactions

Problem:
    Firstly a query is done returning several beans. The query has the readonly attribute set to true
    Next a bean is retrieved which is cached in the previous query.
    The bean is changed but fails to update to DB as the readonly attirbute has been set to true when the query was done.


Question:
Is there a way to change the status of the bean to be updated or can I remove the bean from cache prior to retrieving the bean for update.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 10:44 pm 
Beginner
Beginner

Joined: Fri Mar 17, 2006 7:30 pm
Posts: 32
I'm not sure I follow here. Are you wanting to update a read only bean? Or is the "update" done inside the database and you want to re-read?

Beans can be removed from the current session via the evict method on the session object.

http://www.hibernate.org/hib_docs/v3/ap ... ssion.html

Is that what you want?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 07, 2006 12:17 am 
Newbie

Joined: Tue Feb 14, 2006 8:25 pm
Posts: 3
HI I want the "update" done after the re-read. I tried the following:

    Ran a query (for validation) with read only true

    Iterated thru the result set and retrieving each bean in list

    Called session.evict(bean) on each bean retrieved
    Re-read (using FindById) the bean to be updated (this bean was one of the results returned in the query)
    Changed bean properties

This still didn't update to the DB even though the session.evict was called it is still re-using the same bean from the query call.


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.