浏览 3617 次
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2008-05-18
private String taskId; private List<TaskProductTypeRelation> tpRelations; ...//getter and setter } public class TaskProductType { private String typeId; private String typeName; ...//getter and setter } public class TaskProductTypeRelation { private String id; private String taskId; private TaskProductType productType; ...//getter and setter } 请教大家如何实现taskRecord的sqlmap的映射实现,来实现insert 一个TaskRecord对象时,自动也insert它的tpRelations属性呢? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-05-19
既然是新手贴,那就自己解决
ibatis不维护orm,select可以通过手工编写sql来维护orm,但是insert就不行,希望以后可以在升级版本中实现该功能 通过如下的方法可以实现insert的 orm The SqlMapClientTemplate also offers a generic execute method, taking a custom SqlMapClientCallback implementation as argument. This can, for example, be used for batching: public class SqlMapAccountDao extends SqlMapClientDaoSupport implements AccountDao { public void insertAccount(Account account) throws DataAccessException { getSqlMapClientTemplate().execute(new SqlMapClientCallback() { public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException { executor.startBatch(); executor.update("insertAccount", account); executor.update("insertAddress", account.getAddress()); executor.executeBatch(); } }); } } |
|
返回顶楼 | |