-->
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.  [ 8 posts ] 
Author Message
 Post subject: nullable="false" vs not null in DDL
PostPosted: Sun Mar 06, 2011 1:06 pm 
Newbie

Joined: Sat Feb 18, 2006 1:44 am
Posts: 15
Its possible to supply the checks like nullable="false" in orm.xml or jpa annotations or hbm xml for entity fields.
Let us say we are coding to a system which is already live and generating the DDL on production is a big no no.
Meaning the actual DDL sql is hand crafted.
In all likelihood the actual ddl would also have a similar not null in its sql.
Question is this: Are we making the Java layer do too much work when the not null check is already there in the database for the column in the table?

Any thoughts?
If we try to insert null data the database would have prevented it because of the not null. The nullable="false" is that not an overhead on the java layer?


Top
 Profile  
 
 Post subject: Re: nullable="false" vs not null in DDL
PostPosted: Sun Mar 06, 2011 7:58 pm 
Regular
Regular

Joined: Sun Aug 01, 2004 6:49 pm
Posts: 76
As far as I know this setting is not used by any other mechanism than DDL generation and bean validation. Since you don't use both, you might not have a problem with performance or other side effects. I would keep it in the code just to have it as a helping documentation.


Top
 Profile  
 
 Post subject: Re: nullable="false" vs not null in DDL
PostPosted: Tue Mar 08, 2011 12:26 am 
Newbie

Joined: Sat Feb 18, 2006 1:44 am
Posts: 15
How can one turn off the validation that will be done on the bean?
Is there any way available or is the only way to do that removng nullable="false"


Top
 Profile  
 
 Post subject: Re: nullable="false" vs not null in DDL
PostPosted: Tue Mar 08, 2011 3:34 am 
Regular
Regular

Joined: Sun Aug 01, 2004 6:49 pm
Posts: 76
raster3 wrote:
How can one turn off the validation that will be done on the bean?
Is there any way available or is the only way to do that removng nullable="false"


Bean validation is not activated by default, so you don't need to do anything:
http://docs.jboss.org/hibernate/stable/ ... e/#d0e3875


Top
 Profile  
 
 Post subject: Re: nullable="false" vs not null in DDL
PostPosted: Tue Mar 08, 2011 5:32 am 
Newbie

Joined: Sat Feb 18, 2006 1:44 am
Posts: 15
It seems to be on.

Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: org.somedomein.entities.User.lastName

Maybe thats because am using spring with the jpa.

I dont really mind it being on. But would like to know how to turn it off?


Last edited by raster3 on Tue Mar 08, 2011 5:52 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: nullable="false" vs not null in DDL
PostPosted: Tue Mar 08, 2011 5:34 am 
Newbie

Joined: Sat Feb 18, 2006 1:44 am
Posts: 15
It seems to be on.

Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: org.somedomain.entities.User.lastName

Maybe thats because am using spring with the jpa.

I dont really mind it being on. But would like to know how to turn it off?


Top
 Profile  
 
 Post subject: Re: nullable="false" vs not null in DDL
PostPosted: Tue Mar 08, 2011 6:41 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I don't really think you can turn some of the basic checking off. You can control if you get an exception or not by changing the nullable="false/true" option. If you are worried about performance (as the original post seems to indicate) I think it is better to get an exception before everything is sent to the database which requires a lot more time.


Top
 Profile  
 
 Post subject: Re: nullable="false" vs not null in DDL
PostPosted: Tue Mar 08, 2011 6:48 am 
Newbie

Joined: Sat Feb 18, 2006 1:44 am
Posts: 15
Agreed.
That sounds all right.

I have posted a similar question about CascadeType.DELETE.
If you get time have a look at it.

viewtopic.php?f=1&t=1009904


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.