Hibernate: getting a record but it's being updated in the database?
- by jack
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.