You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Robert Glover <ro...@yahoo.com> on 2008/07/23 17:03:22 UTC
question on default values in Ibator Insert
�� Disclaimer:� I think Ibator is the greatest thing since bread. Ibator rocks!
��� A programmer who has taken over an Ibatis Ibator program I wrote, asked me about the behavior of an Ibator generated INSERT statement as regards a column that allows nulls but has a default value.� This developer would like to know how to make Ibator use the default value of the column when the INSERT occurs.�
�� In looking at the INSERT statement which iBator generates, It looks to me that it sets the column to null when the property in the domain object does not have a value for that column.� Oracle subsequently does not insert the default value because, apparantly, setting the column to null seems to be considered an override of the default value.
�� Is there any value I can set the property in the domain object to, so that when I pass it to the Ibator Insert it will use the default value?
Thank you in advance,
a great iBator Fan,
Robert
Re: question on default values in Ibator Insert
Posted by Jeff Butler <je...@gmail.com>.
I've added an insertSelective method to ibator in SVN. It works as I expect
in my unit tests: the column default value is used if the corresponding
property in the object is null.
Give it a try and let me know if it meets your needs.
Jeff Butler
On Wed, Jul 23, 2008 at 11:47 AM, Jeff Butler <je...@gmail.com> wrote:
> I'm glad you like ibator.
>
> It sounds like the only way to force the default value is to not send the
> column on the insert statement. This would require a new ibator method -
> like insertSelective (analgous to the current updateByXXXSelective
> methods). Its probably not too difficult to do - I'll take a look.
>
> Jeff Butler
>
> On Wed, Jul 23, 2008 at 10:03 AM, Robert Glover <
> robertgloverjr@yahoo.com> wrote:
>
>> Disclaimer: I think Ibator is the greatest thing since bread.
>> Ibator rocks!
>>
>> A programmer who has taken over an Ibatis Ibator program I wrote,
>> asked me about the behavior of an Ibator generated INSERT statement as
>> regards a column that allows nulls but has a default value. This developer
>> would like to know how to make Ibator use the default value of the column
>> when the INSERT occurs.
>>
>> In looking at the INSERT statement which iBator generates, It looks to
>> me that it sets the column to null when the property in the domain object
>> does not have a value for that column. Oracle subsequently does not insert
>> the default value because, apparantly, setting the column to null seems to
>> be considered an override of the default value.
>>
>> Is there any value I can set the property in the domain object to, so
>> that when I pass it to the Ibator Insert it will use the default value?
>>
>> Thank you in advance,
>> a great iBator Fan,
>> Robert
>>
>>
>>
>
Re: question on default values in Ibator Insert
Posted by Jeff Butler <je...@gmail.com>.
I'm glad you like ibator.
It sounds like the only way to force the default value is to not send the
column on the insert statement. This would require a new ibator method -
like insertSelective (analgous to the current updateByXXXSelective
methods). Its probably not too difficult to do - I'll take a look.
Jeff Butler
On Wed, Jul 23, 2008 at 10:03 AM, Robert Glover <ro...@yahoo.com>
wrote:
> Disclaimer: I think Ibator is the greatest thing since bread. Ibator
> rocks!
>
> A programmer who has taken over an Ibatis Ibator program I wrote, asked
> me about the behavior of an Ibator generated INSERT statement as regards a
> column that allows nulls but has a default value. This developer would like
> to know how to make Ibator use the default value of the column when the
> INSERT occurs.
>
> In looking at the INSERT statement which iBator generates, It looks to
> me that it sets the column to null when the property in the domain object
> does not have a value for that column. Oracle subsequently does not insert
> the default value because, apparantly, setting the column to null seems to
> be considered an override of the default value.
>
> Is there any value I can set the property in the domain object to, so
> that when I pass it to the Ibator Insert it will use the default value?
>
> Thank you in advance,
> a great iBator Fan,
> Robert
>
>
>