Hibernate version: 3
MySQL 5.0.12
Driver jdbc 3.1.10
Hi,
We use Hibernate 3 in a Java project, with Tomcat 5.5.9, Struts 1.2.7 and MySQL 5.0.12 (which is in a beta version).
We also use a tomcat DBCP Pool for Hibernate.
We've found a problem while we were running load tests: we use session.get() to load an object from the database. This method is expected to return null only if there no row is found in the database.
BUT, sometimes, this method does return null even though the object exist in the database. We're sure that this object exist because in all threads, we call session.get() with the same id and most of them manage to load the object.
If we loop until session.get() loads the object, it's OK but we found that a little bit strange...
If it was MySQL that was not able to accept the load, I think we would have somme exceptions like "too many connections", "try restarting transaction", "pool exhausted", etc. We also get those kind of exceptions but it's "normal".
So, I'd like to know if session.get() should not return null if and only if no row is not found in the database ?
Do you think that the problem is due to MySQL 5 (which is in beta), Hibernate, or the mapping ?
Thank you.
Note that we work with transactions. The default level in MySQL is SERIALIZATION but we got the same problem with READ COMMITTED.
This is an extract of the code :
Code:
try {
session = HibernateUtil.currentSession();
tx = session.beginTransaction();
Topic topic = (Topic) session.get(Topic.class, topicId);
if (topic==null)
{
....
}
else
{
//update the topic
....
}
tx.commit();
}
catch (HibernateException hex)
{
if (tx != null)
tx.rollback();
}
catch (Exception ex)
{
if (tx != null)
tx.rollback();
}
finally {
if (session != null)
HibernateUtil.closeSession();
}