ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: Inserting Default values if object member is null
Date Mon, 14 Nov 2005 19:34:05 GMT
You are right, you can't, because there is no need, since the database
supports this natively.

 

Niels

 

________________________________

From: Jason Hall [mailto:JHall@cihi.ca] 
Sent: maandag 14 november 2005 20:33
To: user-java@ibatis.apache.org
Subject: RE: Inserting Default values if object member is null

 

I don't want to insert null in the database, i want to insert -1 because
the database column is set to not null.

Maybe Ibatis does not support this.

 

________________________________

From: Niels Beekman [mailto:n.beekman@wis.nl] 
Sent: Monday, November 14, 2005 2:28 PM
To: user-java@ibatis.apache.org
Subject: RE: Inserting Default values if object member is null

You should use the DTD (http://ibatis.apache.org/dtd/sql-map-2.dtd). The
property is actually nullValue, in your example:

 

When iBATIS finds -999 in the Dummy.id-property it will insert null into
the database, when null is found in the database, iBATIS will put -999
in the Dummy.id-property.

 

________________________________

From: Jason Hall [mailto:JHall@cihi.ca] 
Sent: maandag 14 november 2005 20:26
To: user-java@ibatis.apache.org
Subject: RE: Inserting Default values if object member is null

 

I tried using null property and i get and sqlmapconfig parsing error -
"null" not a valid property.

 

<parameterMap id="paramMap" class="Dummy" >
  <parameter property="id"  jdbcType="NUMERIC" null ="-999"/>
  <parameter property="name" jdbcType="VARCHAR" />
  <parameter property="flag" jdbcType="NUMERIC" />
  <parameter property="ndate" jdbcType="DATE" />
</parameterMap>

 

 

________________________________

From: Nathan.Maves@Sun.COM [mailto:Nathan.Maves@Sun.COM] 
Sent: Monday, November 14, 2005 2:24 PM
To: user-java@ibatis.apache.org
Subject: Re: Inserting Default values if object member is null

Whoops.... wrong attribute. 

 

You need to use null="" and not nullValue.

 

This should substitute the given value for any property that is null.

 

Nathan

 

On Nov 14, 2005, at 12:09 PM, Jason Hall wrote:

 

Yah, but the db column is set to not null, so you would get a database
error.

I've tried that anyhow, and got that not null error.  I believe the
nullValue is used for a replacement to insert a null value not to define
a default in the

event the object property is null.

 

thx:)

 

 

________________________________

From: Nathan.Maves@Sun.COM [mailto:Nathan.Maves@Sun.COM] 
Sent: Monday, November 14, 2005 2:05 PM
To: user-java@ibatis.apache.org
Subject: Re: Inserting Default values if object member is null

You can specify your insert sqlmap to use a ParameterMap and set the
nullValue property on the specific column. 

 

Nathan

 

On Nov 14, 2005, at 11:16 AM, Jason Hall wrote:

 

Hi,

 

I just want to know if an object member is set to null and the database
column is configured as not null, 

is there a way in the sqlmapconfig.xml to set a default value say -1 in
a parameter map.

I've used nullValue but this is not exactly what i want. I need a
default value like a database default.

 

Thanks,

 

JH.

 

 

 


Mime
View raw message