Hi,
These lines are repeated in two places in my project :
Code:
session = HibernateUtil.getSessionFactory().openSession();
tx = session.beginTransaction();
As you know, they are using HibernateUtil class, which is downloadable from hibernate web site as an example. (It's the latest version).
One on these lines executes very fast, and the other one, very slowly! What could cause this?
Hibernate version: 3.0
Mapping documents:Code between sessionFactory.openSession() and session.close():
Code:
try
{
session = HibernateUtil.getSessionFactory().openSession();
tx = session.beginTransaction();
Query q = session.createQuery("select o from WindowTO as o where id=" + dto.getId() + " and deleted=0");
List objects = q.list();
//assert(objects.size() <= 1);
Iterator iter = objects.iterator();
WindowTO cur = null;
while (iter.hasNext())
{
cur = (WindowTO) iter.next();
cur.setKeypad_address(dto.getKeypad_address());
cur.setLed_address(dto.getLed_address());
cur.setActive(dto.getActive());
cur.setCode(dto.getCode());
cur.setTitle(dto.getTitle());
cur.setDeleted(dto.getDeleted());
cur.setIsSoftware(dto.getIsSoftware());
session.save(cur);
break;
}
tx.commit();
session.close();
AND
Code:
try
{
session = HibernateUtil.getSessionFactory().openSession();
tx = session.beginTransaction();
Query q = session.createQuery("select o from QueueTO as o where id=" + dto.getId() + " and deleted=0");
List objects = q.list();
//assert(objects.size() <= 1);
Iterator iter = objects.iterator();
QueueTO cur = null;
while (iter.hasNext())
{
cur = (QueueTO) iter.next();
cur.setName(dto.getName());
cur.setRank(dto.getRank());
cur.setDeleted(dto.getDeleted());
session.save(cur);
break;
}
tx.commit();
session.close();
}
Full stack trace of any exception that occurs:
Name and version of the database you are using: Oracle 10g
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: