-->
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: Is not null necessary for Insert
PostPosted: Fri Aug 18, 2006 6:21 am 
Newbie

Joined: Thu Jul 27, 2006 10:35 am
Posts: 16
Hi All

I am using Hibernate 2.

Currently I have a table which has all fields as NOT NULL in the database as well as in the Hibernate mappings. WE added a new field which is a nullable field in the database table.

When I am inserting in this table object via Hibernate
I call all the setter for all the relevant columns on the Hibernate domain object.

But what i see from the Hibernate logs is that for this specific (nullable) column its getting the value as NULL in the setter method.

I have specified not-null as false for this field in the xml mapping

I also printed out the value being passed just before the setter . it gives me the value correctly in the print statement

Do post your reply


Regards


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 11:04 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
not-null isn't necessary for input at all. Hibernate wouldn't be automatically setting any property to null. It only inserts what it has in the objects

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject: not null field forced by Hibernate
PostPosted: Fri Aug 18, 2006 11:21 am 
Newbie

Joined: Thu Jul 27, 2006 10:35 am
Posts: 16
Hi All

Yeah my understanding was the same.

But in my case somehow Hibernate is forcing the value for the specific field as null no wonder why.

I have print statements in both the getter/setter of the current Hibernate domain object in question

I can see the set is called correctly with the value
but the get method returns null.

The data type & column size , mapping name in xml, field name seems to be correct is exactly in line with what I have for other columns I am inserting & they are getting successfully inserted only this field is going as null value.


The only difference is this is nullable field & the rest are not nullable.

One more thing I added this column as add column syntax in ORacle & was not part of the initial create statement but I guess that wont be the cause of the problem in any way


Regards


Top
 Profile  
 
 Post subject: not null value
PostPosted: Fri Aug 18, 2006 11:25 am 
Newbie

Joined: Thu Jul 27, 2006 10:35 am
Posts: 16
Here is what the Hibernate logs look like

2006-08-18 20:29:34,976 [ExecuteThread: '10' for queue: 'default'] DEBUG net.sf.hibernate.type.LongType - binding '6' to parameter: 1
2006-08-18 20:29:34,976 [ExecuteThread: '10' for queue: 'default'] DEBUG net.sf.hibernate.type.DateType - binding '18 August 2006' to parameter: 2
2006-08-18 20:29:34,976 [ExecuteThread: '10' for queue: 'default'] DEBUG net.sf.hibernate.type.StringType - binding 'Open' to parameter: 3
2006-08-18 20:29:34,976 [ExecuteThread: '10' for queue: 'default'] DEBUG net.sf.hibernate.type.LongType - binding null to parameter: 4
2006-08-18 20:29:34,976 [ExecuteThread: '10' for queue: 'default'] DEBUG net.sf.hibernate.type.LongType - binding '241' to parameter: 5


If you look the parameter 4 its binding a null value. where as like all other parameters I am setting this field in the same way.


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.