-->
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.  [ 6 posts ] 
Author Message
 Post subject: empty string is inserting as null value
PostPosted: Fri Jun 03, 2005 8:01 am 
Newbie

Joined: Fri Jun 03, 2005 7:54 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: Hibernate 2.1.8

Mapping documents: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="atrem.osa.storage.provider.jdbc.connector.xdata.XDataDBEvent" table="events">
<id name="eve_id" column="eve_id" type="long">
<generator class="native"/>
</id>
<property name="eve_code" type="integer" column="eve_code"/>
<property name="eve_level" type="integer" column="eve_level"/>
<property name="eve_type" type="integer" column="eve_type"/>
<property name="eve_start_time" type="timestamp" column="eve_start_time"/>
<property name="eve_end_time" type="timestamp" column="eve_end_time"/>
<property name="eve_timestamp" type="timestamp" column="eve_timestamp"/>
<property name="eve_store_time" type="timestamp" column="eve_store_time"/>
<property name="eve_sample_value" type="double" column="eve_sample_value"/>
<property name="eve_value" type="string" length="1000" column="eve_value"/>
<property name="eve_acceptedby" type="string" length="200" column="eve_acceptedby"/>
<property name="eve_comment" type="string" length="2000" column="eve_comment"/>
<property name="eve_status" type="short" column="eve_status"/>
<property name="eve_origin" type="byte" column="eve_origin"/>
<many-to-one name="variable"
class="atrem.osa.storage.provider.jdbc.connector.xdata.XDataDBVariable" foreign-key="eve_fk_var_id">
<column name="eve_var_id"/>
</many-to-one>
</class>
</hibernate-mapping>


When I'm trying to save new value in database, and field eve_acceptedby in class is set as empty string ("") i get null value in database (and i would expect empty string value too).
Anyone knows why?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 8:39 am 
Newbie

Joined: Fri Jun 03, 2005 7:54 am
Posts: 3
I guess i know the answer, for database there is no difference between empty string and null value.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 9:31 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi

An empty string and an null value has an difference.

If you have null value in the database you will definitely get a CGLIB error.

So we have to keep only empty string in Database.

Check the manual and try to find a answer?

Do post the answer?

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 11:02 am 
Beginner
Beginner

Joined: Thu May 26, 2005 12:31 pm
Posts: 25
which is your database? Oracle?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 11:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
An empty string and an null value has an difference.


That depends on your database.

Oracle as mentioned, for example, has the really great feature (sarcasm) where an empty string used as the "new value" in an insert or update statement is actually converted to a null.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 1:00 am 
Newbie

Joined: Fri Jun 03, 2005 7:54 am
Posts: 3
Yes, that was Oracle, so I "discovered" such thing like you wrote steve.


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