ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jozef Hribik <jozef.hri...@apsoft.sk>
Subject Re: how to use id from nextval?
Date Mon, 15 May 2006 11:30:39 GMT
Hi,

try this

    <selectKey keyProperty="id" resultClass="int">
      SELECT nextval('administrator_ID_administrator_seq');
    </selectKey>

in czech/slovak language: iBatis najprv ulozi ziskanu hodnotu nextval do 
property "id" JavaBeanu Administartor, na to sluzi atribut 
keyProperty="id", potom zavola INSERT ... Tvoj selectKey isiel do 
vzduchoprazdna.
 
Jozef


CIJOML wrote:

>Hello,
>
>I am solving one more problem (probably simple) - how to set up id returned by 
>nextval??? I set it up like in oracle example in manual, only changed it fit 
>to postgresql environment:
>
>  <insert id="insertAdministrator" parameterClass="Administrator">
>    <selectKey resultClass="int">  <-- which resultclass?? -->
>      SELECT nextval('administrator_ID_administrator_seq');
>    </selectKey>
>
>    INSERT INTO
>    ADMINISTRATOR (ID_ADMINISTRATOR,JMENO,PRIJMENI,EMAIL,PASSWORD,NICK)
>    values (#id#,#jmeno#,#prijmeni#,#email#,#password#,#nick#)
>  </insert>
>
>Calling this manually in tora I get:
>
>#|nextval
>------------
>1|75
>
>
>In code I call it like:
>
>            Administrator newAdministrator = new Administrator();
>	    newAdministrator.setId();  //<--- how??
>            newAdministrator.setJmeno("Michal");
>            newAdministrator.setPrijmeni("Semler");
>            newAdministrator.setEmail("nasrat@aaa.cz");
>            newAdministrator.setPassword("testovaci");
>            newAdministrator.setNick("CIJOML");
>            sqlMap.insert("insertAdministrator", newAdministrator);
>
>Thank you for your help
>
>Michal
> 
>
>
>__________ Informacia od NOD32 1.1537 (20060514) __________
>
>Tato sprava bola preverena antivirusovym systemom NOD32.
>http://www.eset.sk
>
>
>
>__________ Informacia od NOD32 1.1537 (20060514) __________
>
>Tato sprava bola preverena antivirusovym systemom NOD32.
>http://www.eset.sk
>
>
>
>  
>


Mime
View raw message