数据库中具有重复值的java Hibernate update语句
在hibernate中使用MYSQL
这是我的更新声明
会议结束了。flush()和会话。我很担心,但我不知道还有别的办法
sessionFactory由spring自动连接
这是在我的dao实现中
这个代码有什么问题
@Override
@Transactional
public void updateCurrency(CurrencyEntity currencyEntity) {
session = sessionFactory.getCurrentSession();
//flush the session sending previously cached SQL statements to the database
session.flush();
//clear the session as we don't want to keep previous entities tracked.
//this avoids the chance of a persistent instance with the same identifier causing problems for the update.
session.clear();
session.update(currencyEntity);
//flush to send the update to the database so any errors are caught immediately
session.flush();
}
共 (0) 个答案