Thanks for the tip Brandon,
That will certainly solve the portability issue and fits well with the
way we have structured our system. The selectKey approach is suitable
given your suggestion.
Thanks Chris

On 18/04/2008, Brandon Goodin <[EMAIL PROTECTED]> wrote:
> What is your overall plan for deployment. Do you have sql scripts that get
> run against the target database to build the tables and such? How will you
> configure the connection url? What i've done in the past is to simply have a
> property file that contains the select key sql in it. I pass this property
> file in when my sqlmap is loaded and use the ${selectQuery} notation in my
> sqlmap.
>
> Brandon
>
>
> On Fri, Apr 18, 2008 at 9:29 AM, Chris Marshall <[EMAIL PROTECTED]>
> wrote:
> > Sorry to bug you again but I think that the problem is related to
> > passing a null primary key in the insert statement when the key is
> > autogenerated (by MySQL).
> > What is the best practice here?  I have tried the following MySQL
> > specific SqlMap snippet with success, but was hoping for a solution
> > portable among databases:
> >
> >
> >  <insert id="insert" parameterClass="net.mycompany.Role">
> >          <selectKey resultClass="java.lang.Integer" keyProperty="roleid">
> >                select LAST_INSERT_ID() AS value
> >          </selectKey>
> >
> >    insert into role (RoleID, ParentID, Name, Notes)
> >    values (#roleid:INTEGER#, #parentid:INTEGER#, #name:VARCHAR#,
> > #notes:VARCHAR#)
> >  </insert>
> >
> > Thanks Chris
> >
> >
> > On 18/04/2008, Brandon Goodin <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > Is this the only insert that is not working for you? Do you have others
> that
> > > are working? What version of iBATIS are you using?
> > >
> > > Brandon Goodin
> >
>
>

Reply via email to