Hi,

You should set the id in your dao class.
Here is an example with a dao using Spring:

public void create(Dept dept) throws DataAccessException
{
String sql = ...
NamedParameterJdbcTemplate template = new
NamedParameterJdbcTemplate(this.getDataSource());
MapSqlParameterSource namedParameters = new MapSqlParameterSource();
...
template.update(sql, namedParameters);
int id = getJdbcTemplate().queryForInt("call identity()");
dept.setDeptId(id);

}

Regards,

Olivier


________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of sunilpatel_10
Sent: Saturday, January 20, 2007 2:25 PM
To: [email protected]
Subject: [flexcoders] FDS createItem - how to find ID of inserted
record?



Hi,

I have a page where I capture DEPT and EMP data. On click of a button
I want to save DEPT record and all the EMP records with ID of newly
created DEPT as a parent. I use FDS, hibernate and db generated IDs.
The problem I am facing is how do I get the ID of DEPT record created
by createitem() and access it to assign this DEPT as a parent of EMP
records that I want to create? If I examine ID of dept object used in
createitem after FDS commit(), it is still 0. Appreciate your help.



 

---------------------

An electronic message is not binding on its sender.

Any message referring to a binding engagement must be confirmed in
writing and duly signed.

---------------------

 


---------------------
An electronic message is not binding on its sender.
Any message referring to a binding engagement must be confirmed in writing and 
duly signed.
---------------------

Reply via email to