Hibernate + mysql 更新时死锁
public class dao_setup {
public XdlSetup selectSetup()
{
XdlSetup setup ;
Session session;
String hql = "from XdlSetup setup";
Transaction tx;
session = HibernateSessionFactory.currentSession();
tx = session.beginTransaction();
setup = (XdlSetup)session.createQuery(hql).uniqueResult() ;
tx.commit() ;
return setup;
}
public void update(XdlSetup setup)
{
Session session = HibernateSessionFactory.currentSession() ;
Transaction tx = session.beginTransaction() ;
System.out.println("test");
session.saveOrUpdate(setup);
tx.commit() ;
}
public static void main(String[] args)
{
XdlSetup set = new dao_setup().selectSetup ();
System.out.println(set.getMasterEmail());
set.setMasterEmail("123456@");
new dao_setup().update( set);
}
}
Deadlock found when trying to get lock; Try restarting transaction message from server: "Lock wait timeout exceeded; try restarting transaction"