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 gu...@cox.net on 2007/04/05 22:21:48 UTC

insert sql and function calls.

Hello All,
I have just started using iBatis, and I have a question about insert statements.
I see, that there is a selectKey for auto generated columns.
My situation is I have table that has primary key which is auto generated using a
sequence. I use the selectKey for this column.
But there is another column, UUID, whose value is generated using a PL/SQL function call.
So my sql is some thing like.

<selectKey resultclass="int" keyproperty="id">select seq.nextval from dual</selectKey>
insert into table (id,uuid,name) values (#id#,new_uuid(),#name#);

Althought this results in proper insertion, the result object's uuid property is not set automatically.
is there a way to have the uuid property of the result object set ?

Similarly what about those columns , who get default values ? Does iBatis populate the
corrosponding properties ?

thanks


Re: insert sql and function calls.

Posted by Nathan Maves <na...@gmail.com>.
I can not think of a way to use the SelectKey tage to accomplish this task.
You might have to pull them before the insert is called.  Just set them on
your user POJO and send it your your insert.

Should be good to go then.

Nahtan

On 4/5/07, gumnaam@cox.net <gu...@cox.net> wrote:
>
> Hello All,
> I have just started using iBatis, and I have a question about insert
> statements.
> I see, that there is a selectKey for auto generated columns.
> My situation is I have table that has primary key which is auto generated
> using a
> sequence. I use the selectKey for this column.
> But there is another column, UUID, whose value is generated using a PL/SQL
> function call.
> So my sql is some thing like.
>
> <selectKey resultclass="int" keyproperty="id">select seq.nextval from
> dual</selectKey>
> insert into table (id,uuid,name) values (#id#,new_uuid(),#name#);
>
> Althought this results in proper insertion, the result object's uuid
> property is not set automatically.
> is there a way to have the uuid property of the result object set ?
>
> Similarly what about those columns , who get default values ? Does iBatis
> populate the
> corrosponding properties ?
>
> thanks
>
>