-->
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: @Column(nullable=true) Problem
PostPosted: Fri Aug 01, 2008 3:50 am 
Regular
Regular

Joined: Wed Apr 09, 2008 10:28 am
Posts: 52
Hi,

i want to set null-constraints on several strings my problem is that when i pass a empty string (e.g. persisting an entity) this constraints does not fire. But i dont want to set every empty string to null by hand before i persist my entity so the constraints fires.
are there any best practises or better workarrounds? btw im using mysql.

thx for your help kukudas


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 03, 2008 5:31 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
An empty string is not the same as a null value. Although searching on the net will reveal different opinions on this matter. Particularly in the Oracle world. Here is some fun reading: http://forums.thedailywtf.com/forums/t/1225.aspx

If you need a central place to check/convert empty strings to null, I think the best bet is to implement an Interceptor. See http://www.hibernate.org/hib_docs/v3/ap ... eptor.html


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.