ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Valerio Bertoldi [Primeur]" <valerio.berto...@primeur.com>
Subject Re: auto-generated key into RDBMS that not support the auto-generated key
Date Thu, 25 May 2006 15:57:48 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Verdana">I think to something like:<br>
<br>
with the <b>table</b>:<br>
</font><br>
<tt>CREATE TABLE <b>CFG.COMMANDS</b> (<br>
&nbsp; id_command VARCHAR ( 50 ) NOT NULL,<br>
&nbsp; descr VARCHAR ( 200 ) NOT NULL,<br>
&nbsp; CONSTRAINT PK_CMD PRIMARY KEY (id_command)<br>
&nbsp; );</tt><br>
<font face="Verdana"><br>
and with <b>Class </b></font><font face="Verdana">com.domain.Command:<br>
<br>
</font><tt>public class <b>Command </b>{<br>
&nbsp; private int id_command;<br>
&nbsp; private String descr;<br>
<br>
&nbsp; public String getDescr() {<br>
&nbsp;&nbsp;&nbsp; return this.descr;<br>
&nbsp; }<br>
&nbsp; public void setDescr(String descr) {<br>
&nbsp;&nbsp;&nbsp; this.descr = descr;<br>
&nbsp; }<br>
&nbsp; public int getId_command() {<br>
&nbsp;&nbsp;&nbsp; return this.id_command;<br>
&nbsp; }<br>
&nbsp; public void setId_command(int id_command) {<br>
&nbsp;&nbsp;&nbsp; this.id_command = id_command;<br>
&nbsp; }<br>
}</tt><font face="Verdana"><br>
</font><font face="Verdana"><br>
an query like:<br>
<br>
</font><tt>&lt;insert id="insertCommands"
parameterClass="com.domain.Command"&gt;<br>
&nbsp; &lt;selectKey resultClass="int" &gt;<br>
&nbsp;&nbsp;&nbsp; <b>SELECT MAX(id_</b></tt><tt><b>command)
AS id_command FROM
CFG.COMMANDS</b><br>
&lt;/selectKey&gt;<br>
insert into CFG.COMMANDS (id_command,descr)<br>
values (#id_command#,#descr</tt><tt>#)<br>
&lt;/insert&gt;</tt><font face="Verdana"><br>
<br>
is it possible ?<br>
<br>
Thank's <br>
&nbsp;&nbsp; Valerio<br>
<br>
</font><br>
Larry Meadors ha scritto:
<blockquote
 cite="mida10a823c0605250654g1620164bw4da838872516fd66@mail.gmail.com"
 type="cite">I do not think I understand the question...if the database
doesn't
  <br>
support auto-generated keys, it'll be awful difficult to get the
  <br>
auto-generated keys...
  <br>
  <br>
Maybe you can clarify your question some.
  <br>
  <br>
Larry
  <br>
  <br>
  <br>
On 5/25/06, Valerio Bertoldi [Primeur]
<a class="moz-txt-link-rfc2396E" href="mailto:valerio.bertoldi@primeur.com">&lt;valerio.bertoldi@primeur.com&gt;</a>
wrote:
  <br>
  <blockquote type="cite">Hi,
    <br>
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 ?
    <br>
    <br>
Thank's
    <br>
&nbsp;&nbsp; Valerio
    <br>
    <br>
    <br>
    <br>
    <br>
  </blockquote>
  <br>
  <br>
  <br>
</blockquote>
</body>
</html>

Mime
View raw message