ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From CIJOML <cij...@volny.cz>
Subject how to use id from nextval?
Date Mon, 15 May 2006 10:42:58 GMT
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
 

Mime
View raw message