It is possible, but a profoundly bad design. What database are you
using that doesn't support this?

Larry


On 5/25/06, Valerio Bertoldi [Primeur] <[EMAIL PROTECTED]> wrote:

 I think to something like:

 with the table:

 CREATE TABLE CFG.COMMANDS (
   id_command VARCHAR ( 50 ) NOT NULL,
   descr VARCHAR ( 200 ) NOT NULL,
   CONSTRAINT PK_CMD PRIMARY KEY (id_command)
   );

 and with Class com.domain.Command:

 public class Command {
   private int id_command;
   private String descr;

   public String getDescr() {
     return this.descr;
   }
   public void setDescr(String descr) {
     this.descr = descr;
   }
   public int getId_command() {
     return this.id_command;
   }
   public void setId_command(int id_command) {
     this.id_command = id_command;
   }
 }

 an query like:

 <insert id="insertCommands" parameterClass="com.domain.Command">
   <selectKey resultClass="int" >
     SELECT MAX(id_command) AS id_command FROM CFG.COMMANDS
 </selectKey>
 insert into CFG.COMMANDS (id_command,descr)
 values (#id_command#,#descr#)
 </insert>

 is it possible ?

 Thank's
    Valerio


 Larry Meadors ha scritto:
I do not think I understand the question...if the database doesn't
 support auto-generated keys, it'll be awful difficult to get the
 auto-generated keys...

 Maybe you can clarify your question some.

 Larry


 On 5/25/06, Valerio Bertoldi [Primeur] <[EMAIL PROTECTED]>
wrote:

Hi,
 is there any possibility to get the auto-generated key from the
INSERT-Statement with the selectKey-Element in RDBMS that not support the
auto-generated key ?

 Thank's
    Valerio










Reply via email to