I have following code:
Code:
try
{
// session.beginTransaction();
CallableStatement st = session.connection().prepareCall("{call storedProcedure(?,?,?,?,?,?,?,?)}"); //insert one row into table
....//set the parameters
st.close();
st = null;
System.out.println("go to commit");
session.getTransaction().commit();
System.out.println("go to after commit");
}
catch (Exception e)
{
System.out.println("Exception happens:"+e);
}
session.flush();
results = session.createCriteria(GroupAccount.class).add(Restrictions.and(Restrictions.eq("accountNo",accountNo), Restrictions.eq("groupID",new Integer(groupID)))).list();
for (ListIterator iter = results.listIterator(); iter.hasNext(); ){
GroupAccount aTrack = (GroupAccount)iter.next();
System.out.println("groupID = "+aTrack.getGroupID()+", naObjID = "+aTrack.getNaObjID()+", accountNo = " +aTrack.getAccountNo());
}
session.close();
When I run, I got the following results:
[java] go to commit
[java] Exception happens:org.hibernate.TransactionException: Transaction not successfully started
However, the new row still be printed out. I checked the database, this row is not there.
What happened? what whould I do the make the consistence between the cache and database?