Hibernate: getting a record but it's being updated in the database?
Posted
by
jack
on Stack Overflow
See other posts from Stack Overflow
or by jack
Published on 2010-12-24T08:06:15Z
Indexed on
2010/12/24
8:54 UTC
Read the original article
Hit count: 238
For some reason Hibernate seems to be keeping my session open and updating the object without me explicitely invoking a save/update/saveorupdate. I guess the session is staying open and it's beeing marked as dirty.
However this is not the desired behaviour, so what's the cleanest way to fix this?
The issue seems to occur because I store a phone number without formatting in the database but the getter of the object returns a formatted telephone number.
My flow: go to a jsp => controller => service => dao
DAO getter function
if(userId != 0) {
return (User)dbFactory.get(User.class, userId);
}
return null;
The service just passes it to the controller and the controller puts te User object in the request scope. I display it on my JSP page using EL.
© Stack Overflow or respective owner