Tag Archives: Hibernate

How to resolve HibernateObjectRetrievalFailureException (org.hibernate.ObjectNotFoundException: No row with the given identifier exists exception)?


Quite recently, we were getting the below exception in one of our stand-alone java application: org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists: [example.hibernate.pojo.Person#10878]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [example.hibernate.pojo.Person#10878] at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:660) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424) at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) at org.springframework.orm.hibernate3.HibernateTemplate.loadAll(HibernateTemplate.java:595) . . . Caused by: org.hibernate.ObjectNotFoundException: No row with […]

org.hibernate.util.JDBCExceptionReporter – Communications link failure | SQL Error: 0, SQLState: 08S01


I noticed an exception like this one in one of our applications’ log and was investigating it. Here’s it: Exception [20:26:51] WARN [org.hibernate.util.JDBCExceptionReporter] – SQL Error: 0, SQLState: 08S01 [20:26:51] ERROR [org.hibernate.util.JDBCExceptionReporter] – Communications link failure Last packet sent to the server was 96429 ms ago. . . . org.springframework.dao.DataAccessResourceFailureException: Cannot open connection; nested exception […]

Hibernate Performance Tuning Tip: Identifying and Resolving N+1 SELECTs Problem


Problem (in Simple Words) Let’s assume that you’re writing code that’d track the price of mobile phones. Now, let’s say you have a collection of objects representing different Mobile phone vendors (MobileVendor), and each vendor has a collection of objects representing the PhoneModels they offer. To put it simple, there’s exists a one-to-many relationship between […]

Criteria Queries vs HQL in Hibernate


Criteria queries are ideal for dynamic queries. It makes the task of adding ordering, leaving some parts (e.g. restrictions) out depending on some parameter. HQL is ideal for static and complex queries coz it it’s much easier to read/understand HQL. It’s a bit more powerful for join queries. There is a difference in terms of […]

Multiple WARs using Hibernate (with c3p0 connection pool) in same app server


A C3P0Registry mbean is already registered. This probably means that an application using c3p0 was undeployed, but not all PooledDataSources were closed prior to undeployment. This may lead to resource leaks over time. Please take care to close all PooledDataSources. We had this problem when we were trying to deploy multiple applications within same app […]

Question: How do I invoke stored procedures/functions using Hibernate?


It’s possible, but not quite easy. If you’re using Spring framework in your project, I’d strongly recommend that you have a look at Spring JDBC and consider it in place of Hibernate atleast for this specific scenario. You’ve got wonderful support there for stored procedures/functions. Well, if you still insist on going ahead with Hibernate/you […]