-->
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: Why Hibernate fires update statement if I change the getter
PostPosted: Tue Jan 12, 2010 6:28 am 
Newbie

Joined: Mon Dec 17, 2007 10:06 am
Posts: 2
Hi,

I'm using Spring & Hibernate with Oracle. In order to deal with the special NULL/empty handling of Oracle, I change the getter method to change NULL to empty string is null

e.g.
public getName(String name) {
if (name != null)
return null;
else
return "";
}

once I change this, I got the hibernate exception saying that I don't have the update permission on the Oracle tables. It's because the Oracle account has only read-only permission.

why got this behaivour? if i remove the check null logic, it's working fine.

thanks!


Top
 Profile  
 
 Post subject: Re: Why Hibernate fires update statement if I change the getter
PostPosted: Tue Jan 12, 2010 8:34 am 
Newbie

Joined: Wed Dec 23, 2009 12:38 pm
Posts: 14
You are changing the value of the name while returning it from the getName() method.

Hibernate will compare the objects by value—not by object identity—to determine if the property’s persistent state
needs to be updated.

As default-access is property, getName() is invoked to check if object's state has changed and hence upate is fired.

Change the field-access to 'field' and no update is fired. like..

default-access="field"


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.