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 CIJOML <ci...@volny.cz> on 2006/05/13 14:32:07 UTC

how to get ID from relation table?

Hello,

I am new to iBatis and I need fill in value into table with foreign key. How 
can I get ID from relation table filled before this table? Does ibatis return 
this value for me?

For example:
Table person with personId, firstName, surName
Table Address with addressId, personId (foreign key), streetName, etc

Now I am able to insert/udpdate/delete rows in person table, but need also 
fill in relation table.

Thanks a lot

Michal

Re: how to get ID from relation table?

Posted by CIJOML <ci...@volny.cz>.
Hi,

It is postgresql with serial (autoupdate/autoincrement key) option.
For example:
CREATE TABLE OS (
  ID_os SERIAL NOT NULL CHECK (ID_os > 0),
  Major_type VARCHAR(20) NOT NULL,
  Sub_type VARCHAR(20) NULL,
  Minor_type VARCHAR(20) NULL,
  Maintanance_level VARCHAR(6) NULL,
  PRIMARY KEY(ID_os)
);

Michal

Dne sobota 13 květen 2006 14:36 James, Steven napsal(a):
> Depend son the database but if it is an auto key just use the select key
> tag. Have a look at the documentation on page 15.
>
> http://cvs.apache.org/dist/ibatis/ibatis.java/docs/iBATIS-SqlMaps-2.pdf
>
>
> ________________________________
>
> From: CIJOML [mailto:cijoml@volny.cz]
> Sent: Sat 13/05/2006 13:32
> To: user-java@ibatis.apache.org
> Subject: how to get ID from relation table?
>
>
>
> Hello,
>
> I am new to iBatis and I need fill in value into table with foreign key.
> How can I get ID from relation table filled before this table? Does ibatis
> return this value for me?
>
> For example:
> Table person with personId, firstName, surName
> Table Address with addressId, personId (foreign key), streetName, etc
>
> Now I am able to insert/udpdate/delete rows in person table, but need also
> fill in relation table.
>
> Thanks a lot
>
> Michal
>
>
>
>
> This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. It may contain proprietary material, confidential
> information and/or be subject to legal privilege. It should not be copied,
> disclosed to, retained or used by, any other party. If you are not an
> intended recipient then please promptly delete this e-mail and any
> attachment and all copies and inform the sender. Thank you.

RE: how to get ID from relation table?

Posted by "James, Steven" <st...@logicacmg.com>.
Depend son the database but if it is an auto key just use the select key tag. Have a look at the documentation on page 15.

http://cvs.apache.org/dist/ibatis/ibatis.java/docs/iBATIS-SqlMaps-2.pdf


________________________________

From: CIJOML [mailto:cijoml@volny.cz]
Sent: Sat 13/05/2006 13:32
To: user-java@ibatis.apache.org
Subject: how to get ID from relation table?



Hello,

I am new to iBatis and I need fill in value into table with foreign key. How
can I get ID from relation table filled before this table? Does ibatis return
this value for me?

For example:
Table person with personId, firstName, surName
Table Address with addressId, personId (foreign key), streetName, etc

Now I am able to insert/udpdate/delete rows in person table, but need also
fill in relation table.

Thanks a lot

Michal




This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.