-->
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: Hibernate throws updates when i'm not expecifing.
PostPosted: Thu Jun 12, 2008 3:20 am 
Newbie

Joined: Thu Jun 21, 2007 12:33 pm
Posts: 7
I have made some changes in my code and now hibernate throws updates but there is no explicit code for this.

The changes consist in modify the setters of the bean for prevent inserts string with blank values, example:

public class Project {
private String name;

public setName(String name){
name=org.apache.commons.lang.StringUtils.trimToNull(name);
this.name = name;
}

}


Now i've got a finder for looking up projects (but not updates just select¡¡), and when the Transaction is committing hibernate begin to throws updates (i can see in the log console).

// Code transaction
HibernateSessionRequestFilter{

public doFilter( ... ){
...
HibernateUtil.currentSession().beginTransaction();
chain.doFilter(request, response);
HibernateUtil.currentSession().getTransaction().commit();
...
}


}

Any explain??, i gues that when i'm finding projects Hibernate calls de setter methods so change the state of the bean if the name field was blank.

Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 9:27 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
So, you're loading a JavaBean, calling a setter, and then closing the session? If the setter is called on the JavaBean, wouldn't it be expected that Hibernate issues an update?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.