public void insertIntoCMS(Agent agent) {
Session session = this.getSession();
session.save(agent);
ConfigInfo configInfo = new ConfigInfo();
String roleid = configInfo.getPropertiesValue("parameter","roleId");
insertIntoAgentRole(agent.getAgentId(),roleid);
}
public void insertIntoAgentRole(final String agentId, final String roleId) {
getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session){
String sql = "insert into p_agentrole (agentid,roleid) values(?,?)";
Query query= session.createSQLQuery(sql);
query.setString(0, agentId);
query.setString(1, roleId);
query.executeUpdate();
return null;
}
});
}Hibernate之使用insert into语句
最新推荐文章于 2022-04-15 11:57:16 发布
本文介绍了一种将Agent对象插入到CMS系统的方法。通过使用Hibernate框架,首先将Agent对象保存到数据库中,然后根据配置文件获取角色ID,并将Agent ID与角色ID一同插入到p_agentrole表中。

728

被折叠的 条评论
为什么被折叠?



