Hi,
According to the documentation it should be easy but it isn't.
The main problem is that, i don't see any sql statement of selectKey in log of  postgresql !!!
When i make a mistake with keyProperty name, it also is correct for ibatis. But when I replace
KeyProperty with something else, or I make a mistake, syntax error is arrisen.
 
Why the selectKey isn't invoked ?
 
With the previous version of jdbc driver (7.4) with database 8.01 and Ibatis 2.00 I had the problem, that selectKey statement was invoked, but it returned always 0
 
Postgresql: 8.01
Jdbc driver: 8.0-311
Ibatis 2.09b
 
Thanks
Darek
 
<insert id="insertCustomerNew" parameterClass="customer">
   <selectKey resultClass="integer" keyProperty="addressId">
                SELECT cast(last_value as int) AS addressId
                FROM addresses_addr_id_seq
   </selectKey>
 
    INSERT INTO ADDRESSES (
      ,ADDR_ID
       STREET
      ,PLACENO
      ,FLATNO
      .....
     )
     VALUES (
       #addressId#
       ,#addressStreet#
      ,#addressPlaceNo#
      ,#addressFlatNo#
      ,#addressCity#
    );
 
    INSERT INTO CUSTOMERS (
       STAT_ID
      ,COMP_ID
      ,ADDR_ID
      ,NUMBER
      ......
    )
    VALUES (
       #stateId#
      ,#compId#
      ,#addressId#
      ,#number#
      ....
    );
  </insert>

Reply via email to