-->
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.  [ 1 post ] 
Author Message
 Post subject: How do I set SQL NULL value to an object's property?
PostPosted: Thu Aug 10, 2006 5:06 am 
Newbie

Joined: Mon Aug 07, 2006 2:08 am
Posts: 5
Hi All,

I have kind of run into this situation wherein I need to set null value to an object's property. I have some existing records in a table and I need to set null value to a column for all of them. I understand the Java null is totally different from a SQL Null. For e.g.

String aString = null;
SomeObject aObject = new SomeObject();
aObject.setSomeProperty(aString );
session.save(aObject);


will not result in the column mapped to the SomeProperty property being set with a SQL Null. What goes through to the table will be the text "null". So querying the following will not retrieve the record,

select * from someTable where someProperty is null

How do I go about setting the SQL null value to the column of a record? One solution I thought about was deleting the record and creating a new object updating all properties except the one I wanted to set SQL null for....but it was impractical in my case as there a lot of records and in my case its difficult to remember all the "other" properties in some collection(difficult? i cudnt think of how to do it :-) )

Please let me know how I can achieve this one....even if its through HQL...Here are some questions you would like answered before u try solving this one..

1. Yes the column of interest is nullable ( but of course!)
2. Yes Its ok if it can be done through HQL
3. I am using Oracle
4. My code runs in a non-managed environment
5. I am not using caching

thanx a tonne in advance...help me out on this one!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.