ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: auto-generated key into RDBMS that not support the auto-generated key
Date Thu, 25 May 2006 16:05:34 GMT
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] <valerio.bertoldi@primeur.com> 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] <valerio.bertoldi@primeur.com>
> 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
>
>
>
>
>
>
>
>
>
>

Mime
View raw message