Transorder:
ORDERITEM:
Test main () public static void main (String [] args) throws HibernateException {Session session = HibernateUtil.currentSession (); Transaction tx = session.beginTransaction (); TransOrder order = new TransOrder (); order.setAcceptType ( "www" ); Order.Setaddress ("Tom"); Order.SetCity ("Changzhou"); OrderItem Item = New ORDERITEM (); item.setItemcount (New Integer (100)); item.setItemMoney ("1200.2"); item. SetitemType ("kysj"); item.setPaperItemId (New Integer (101)); item.setResourceItemId (New Integer); Order.GetOrderItems (); add (item); item.setTransorder (Order);
Session.save (Order); session.flush (); tx.commit (); hibernateutil.closesis ();
Error Message:
.
Solution:
Actually the problem of MS, it took a few days, wasted,
Generally when you perform multiple statements on a SQL Server's JDBC, or manual transaction status (AutoCommit = false) and use Direct (SELECTMETHOD = Direct) mode. Direct mode is the default mode. Solution When you When using manual transaction mode, you must set the value of the SelectMethod property to Cursor, or make sure there is only one statement operation on your connection. Set hibernate.cfg.xml
SELECTMETHOD = CURSOR; default is selectmethod = DIRET;
I am using it in Hibernate Syn, I have changed. HibernateSynchronizer file, did not change hibernate.cfg.xml, huh, halo.
It is best to change the two files, and hibernate.cfg.xml can run successfully.