-->
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.  [ 2 posts ] 
Author Message
 Post subject: Queries within a transaction cause an update
PostPosted: Thu Nov 05, 2009 2:46 pm 
Beginner
Beginner

Joined: Mon Nov 20, 2006 2:46 pm
Posts: 32
I'm seeing some behavior with Hibernate I did not expect. Basically, I load an entity instance from the database, apply some changes to the fields, start a transaction, then run a (select) query; at this point the changes to the entity are being run against the database. I know this because I get a constraint violation (which I was trying to prevent via the query). I haven't called saveOrUpdate() on the modified entity at this point however, so I did not expect it to be persisted. Here's a simplified version of the code:

Code:
Account account = accountDao.loadById(accountId);
account.setEmail("existing-email@example.com");
// Start transaction via Spring annotation
List existing = accountDao.findByEmail(account.getEmail());
// Above line causes org.postgresql.util.PSQLException:
// ERROR: duplicate key violates unique constraint "account_email_key"


Can someone give me some insight as to what is happening here?

Running Hibernate 3.3.1.GA within JBoss 5.0.1.GA.


Top
 Profile  
 
 Post subject: Re: Queries within a transaction cause an update
PostPosted: Thu Nov 05, 2009 2:49 pm 
Beginner
Beginner

Joined: Mon Nov 20, 2006 2:46 pm
Posts: 32
My apologies for the multiple posts, please continue here:

https://forum.hibernate.org/viewtopic.php?f=1&t=1000798


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