-->
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.  [ 4 posts ] 
Author Message
 Post subject: Null values coming from the database
PostPosted: Tue Jun 14, 2005 12:02 pm 
Newbie

Joined: Tue Jun 14, 2005 11:55 am
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1.6

Name and version of the database you are using: Oracle 8i


I have a question about dealing with null values coming from the database. Currently on our setters, we have code to test if the value being set is null and if so, set it to empty string. This has the unwanted side affect of making the object dirty even and causing update statements to fire for read only operations. What is the preferred way to deal with null values coming from the database. We would prefer to not have null checks all over the client code for this. While I realize this problem is independent of hibernate, I thought someone here might have a more elegant way of dealing with this dreaded scenario.

Thanks in Advance.
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 8:07 pm 
Beginner
Beginner

Joined: Mon Jun 13, 2005 5:52 pm
Posts: 43
What if you instead put the null check on the getter, and then have hibernate use attribute-level access? (I'm not advocating this as a solution, though.)


Top
 Profile  
 
 Post subject: Re: Null values coming from the database
PostPosted: Tue Jun 14, 2005 10:04 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
shoemam wrote:
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1.6

Name and version of the database you are using: Oracle 8i


I have a question about dealing with null values coming from the database. Currently on our setters, we have code to test if the value being set is null and if so, set it to empty string. This has the unwanted side affect of making the object dirty even and causing update statements to fire for read only operations. What is the preferred way to deal with null values coming from the database. We would prefer to not have null checks all over the client code for this. While I realize this problem is independent of hibernate, I thought someone here might have a more elegant way of dealing with this dreaded scenario.

Thanks in Advance.
Mike


What if you move your null checks to your getter methods ? Does that have the same side effect of making the object dirty ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 10:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is a FAQ. You use a UserType.


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