You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Mark Volkmann <ma...@ociweb.com> on 2007/03/20 17:25:56 UTC

Postgres and generated keys

Abator generates this in an SqlMap.xml file.

   <insert id="abatorgenerated_insert"  
parameterClass="com.savealot.xademo.model.Address" >
     <!--
       WARNING - This element is automatically generated by Abator  
for iBATIS, do not modify.
       This element was generated on Tue Mar 20 11:15:50 CDT 2007.
     -->
     insert into sal.address (street, city, state, zip)
     values (#street:VARCHAR#, #city:VARCHAR#, #state:VARCHAR#,  
#zip:INTEGER#)
     <selectKey resultClass="java.lang.Integer" keyProperty="id" >
       Postgres
     </selectKey>
   </insert>

When I attempt an insert that uses this, it chokes on "Postgres"  
inside the selectKey element.

Perhaps I'm doing something wrong in my AbatorConfig.xml. Here's the  
part that pertains to the address table.

     <table schema="sal"
       tableName="address" domainObjectName="Address">
       <generatedKey column="id" sqlStatement="Postgres"  
identity="true"/>
     </table>

Is the value for the sqlStatement attribute wrong?

Re: Postgres and generated keys

Posted by Graeme J Sweeney <ib...@gjsweeney.com>.
On Tue, 20 Mar 2007, Mark Volkmann wrote:


> Perhaps I'm doing something wrong in my AbatorConfig.xml. Here's the part 
> that pertains to the address table.
>
>   <table schema="sal"
>     tableName="address" domainObjectName="Address">
>     <generatedKey column="id" sqlStatement="Postgres" identity="true"/>
>   </table>
>
> Is the value for the sqlStatement attribute wrong?

Something like .....

<generatedKey column="id" sqlStatement="SELECT nextVal('address_id_seq ')" identity="false" />

-- 
Graeme -

Re: Postgres and generated keys

Posted by Jeff Butler <je...@gmail.com>.
Postgres is not one of the supported dialects in Abator.  All this means is
that Abator does come preloaded with the proper statement to retrieve the
generated key.  So instead of "postgres", you'll need to figure out the
right statement yourself.

Jeff Butler




On 3/20/07, Mark Volkmann <ma...@ociweb.com> wrote:
>
> Abator generates this in an SqlMap.xml file.
>
>   <insert id="abatorgenerated_insert"
> parameterClass="com.savealot.xademo.model.Address" >
>     <!--
>       WARNING - This element is automatically generated by Abator
> for iBATIS, do not modify.
>       This element was generated on Tue Mar 20 11:15:50 CDT 2007.
>     -->
>     insert into sal.address (street, city, state, zip)
>     values (#street:VARCHAR#, #city:VARCHAR#, #state:VARCHAR#,
> #zip:INTEGER#)
>     <selectKey resultClass="java.lang.Integer" keyProperty="id" >
>       Postgres
>     </selectKey>
>   </insert>
>
> When I attempt an insert that uses this, it chokes on "Postgres"
> inside the selectKey element.
>
> Perhaps I'm doing something wrong in my AbatorConfig.xml. Here's the
> part that pertains to the address table.
>
>     <table schema="sal"
>       tableName="address" domainObjectName="Address">
>       <generatedKey column="id" sqlStatement="Postgres"
> identity="true"/>
>     </table>
>
> Is the value for the sqlStatement attribute wrong?
>