siamackj wrote:
HI:
Thanks for your reply, It actually worked. I was under the impression that a call to session.clear() at the end of the transaction would clear all the session not that I have to call session.clear() after each look up by ID.
I also managed to get around the problem by providing a thrid method that runs all the test methods within a transaction. It is only this method that commits the transaction and closes the session (This should work only for tests that does only lookups). For those who may want to consider it here is the code:
public void testmethods(){
try {
HibernateUtil util = HibernateUtil.getInstance();
getQueueById();
getQueueByName();
util.commitTransaction();
util.closeSession();
}catch(Exception e){
}
}
private void getQueueById() {
try {
HibernateUtil util = HibernateUtil.getInstance();
Queue q = qDAO.getQueueById(q1.getId());
checkQueue(
"system",
"active",
"iam",
"First Queue",
"key word1",
q1);
q = qDAO.getQueueById(q2.getId());
checkQueue(
"lotus",
"inactive",
"lot",
"Second Queue",
"key word2",
q);
q = qDAO.getQueueById(q3.getId());
checkQueue(
"websphere",
"active",
"was",
"third Queue",
"key word3",
q);
q = qDAO.getQueueById(q4.getId());
checkQueue(
"tivoli",
"active",
"tiv",
"Fourth Queue",
"key word3",
q);
} catch (Exception e) {
fail("An unexpected exception has occured --> " + e.getMessage());
}
}
private void getQueueByName() {
try {
Queue q = qDAO.getQueueByName(q1.getQueueName());
checkQueue(
"system",
"active",
"iam",
"First Queue",
"key word1",
q1);
q = qDAO.getQueueByName("lotus");
checkQueue(
"lotus",
"inactive",
"lot",
"Second Queue",
"key word2",
q);
q = qDAO.getQueueByName("websphere");
checkQueue(
"websphere",
"active",
"was",
"third Queue",
"key word3",
q);
q = qDAO.getQueueByName("tivoli");
checkQueue(
"tivoli",
"active",
"tiv",
"Fourth Queue",
"key word3",
q);
} catch (Exception e) {
fail("An unexpected exception has occured --> " + e.getMessage());
}
}
private void checkQueue(
String name,
String status,
String tName,
String desc,
String kWord,
Queue q) {
assertEquals(name, q.getQueueName());
assertEquals(status, q.getQueueStatus());
assertEquals(tName, q.getQueueTeamName());
assertEquals(desc, q.getQueueDescription());
assertEquals(kWord, q.getQueueKeywords());
}