Rahul,
 
My experience with this tag is you use it to define a query to determine
your primary key, in the absence of, say an IDENTITY column.
 
You need to specify the keyProperty attribute if you want the following
SQL to be able to utilize the result of the query.  In the following
example, I utilize an integer based primary key column.  The following
allows me to manage the primary keys myself, without an
auto-incrementing identity column.
 
Ex: 
  <selectKey resultClass="int" keyProperty="id">
    SELECT max( pkey_column)+ 1 AS id from <table>
  </selectKey> 

  INSERT INTO <table>         
  ( pkey_column,
   <other column>,
   <other column>,
     ... )
  VALUES  
   ( #id:INTEGER#,
    value,
    value,
...)
 
 
I guess there is a possibility that you could have concurrency issues,
unless you synchronize access on the DAO methods invoking this
statement.  Otherwise, you could experience another thread attemping an
insert between the <selectKey> query to determine the next value, and
the actual insert in your statement.  
 
-Kevin
 

    

-----Original Message-----
From: Rahul Saluja [mailto:rahul.sal...@vnl.in] 
Sent: February 12, 2009 12:00 PM
To: user-java@ibatis.apache.org
Subject: RE: KeyProperty attribute in Selectkey Tag



         

        Does anybody care to reply.

         

         

        Please.

        
  _____  


Reply via email to