ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Hall" <JH...@cihi.ca>
Subject RE: Selectkey Tag Question
Date Wed, 06 Apr 2005 16:12:57 GMT
Thanks!

-----Original Message-----
From: Brandon Goodin [mailto:brandon.goodin@gmail.com]
Sent: Wednesday, April 06, 2005 12:11 PM
To: ibatis-user-java@incubator.apache.org
Subject: Re: Selectkey Tag Question


the selectKey places the value in your java object. The reference you
pass into your insert will then contain the id.

--- service ---

SomeObject someObject = new SomeObject();
...
myDao.insertSomeObject(someObject);

Integer myId = someObject.getObjectId();

... call some other Dao and pass the myId



--- Dao ---
... insertSomeObject(SomeOjbect someObject) {
  sqlMap.insert("myInsertStatement",someObject);
}



--- sql map ---
<insert...>
<selectKey keyProperty="objectId" resultClass="integer">
 ...
</selectKey>
...
</insert>

Hope that helps,
Brandon

On Apr 6, 2005 9:46 AM, Jason Hall <JHall@cihi.ca> wrote:
>  
> 
> Hi, 
> 
> I'm using Oracle sequences.  I just wanted to know when using the
> <selectKey> tag, if there is a way to fetch that key in java 
> 
> after it has been inserted.  I need this key for other tables. 
> 
> Thanks, 
> 
> Jason Hall

Mime
View raw message