Thanks for you reply Anthony. As I was trying to fix the problem. I realized that If I run the code alone (while commenting out all other test cases) it works. However, I run it in conjunction with the following test case it fails(Even it does not get to the point of generating update sql):
public void testGetRouteSequenceById() {
try {
HibernateUtil util =HibernateUtil.getInstance();
Session session = util.getSession();
util.beginTransaction();
RouteSequenceDAO routeDAO = new RouteSequenceDAO();
RouteSequence r = routeDAO.getRouteSequenceById(1);
assertEquals(Constants.CONNECTIVITY, r.getKey().trim());
assertEquals("3,6,12,89,12,50,21", r.getValue().trim());
session.clear();
r = routeDAO.getRouteSequenceById(2);
assertEquals(Constants.APPLICATION, r.getKey().trim());
assertEquals("13,26,5,1,62,25", r.getValue().trim());
session.clear();
r = routeDAO.getRouteSequenceById(3);
assertEquals(Constants.SYSTEM, r.getKey().trim());
assertEquals("29,9,15,11,31,25", r.getValue().trim());
session.clear();
util.commitTransaction();
session.close();
} catch (Exception e) {
fail("An unexpected exception has occured --> " + e.getMessage());
HibernateUtil.getInstance().closeSession();
}
}
Only the following sql is generated which is related to the above testcase:
8/20/04 16:38:38:674 EDT] 92dcf65 SystemOut O Hibernate: select routeseque0_.ROUTE_SEQ_ID as ROUTE_SE1_0_, routeseque0_.KEY as KEY0_, routeseque0_.VALUES as VALUES0_ from ccol.ROUTE_SEQ routeseque0_ where routeseque0_.ROUTE_SEQ_ID=?
[8/20/04 16:38:38:721 EDT] 92dcf65 SystemOut O Hibernate: select routeseque0_.ROUTE_SEQ_ID as ROUTE_SE1_0_, routeseque0_.KEY as KEY0_, routeseque0_.VALUES as VALUES0_ from ccol.ROUTE_SEQ routeseque0_ where routeseque0_.ROUTE_SEQ_ID=?
[8/20/04 16:38:38:752 EDT] 92dcf65 SystemOut O Hibernate: select routeseque0_.ROUTE_SEQ_ID as ROUTE_SE1_0_, routeseque0_.KEY as KEY0_, routeseque0_.VALUES as VALUES0_ from ccol.ROUTE_SEQ routeseque0_ where routeseque0_.ROUTE_SEQ_ID=?
I really do not understand what is going on. I would appreciate if you can give me some hints on why it works when I run it alone. Just for the sake of completeness , here is also the whole testcase for the update :
public void testUpdateRouteSequence(){
try{
HibernateUtil util = HibernateUtil.getInstance();
Session session = util.getSession();
RouteSequenceDAO routeDAO = new RouteSequenceDAO();
util.beginTransaction();
RouteSequence r = routeDAO.getRouteSequenceById(super.getTableId("ROUTE_SEQ_ID","KEY",Constants.CONNECTIVITY,"CCOL.ROUTE_SEQ"));
r.setValue("1;2;3;4;5");
session.update(r);
util.commitTransaction();
assertEquals(r.getValue(),"1;2;3;4;5");
}catch(Exception e){
fail("An unexpected exception has occured --> " + e.getMessage());
HibernateUtil.getInstance().closeSession();
}
}
|