This piece of code has been running for some months with any problem until today. I suddenly run into an exception. Since I am unable to explain any causes, I try replacing the find method with the findByNamedParam method. This hack solves the problem. Interesting enough, another version of the same piece code is running fine as I am writing.
It is not the first time that I run into a Hibernate issue from nowhere and I can't explain how it occurs.
Can anyone share a light in this regard?
Hibernate version:
3.x
Code between sessionFactory.openSession() and session.close():
find("select e from Entry e left join fetch e.addresses a left join fetch e.reviews r left join fetch r.images where e.id = ?", entryId);
Full stack trace of any exception that occurs:
Data access failure: could not execute query; nested exception is org.hibernate.exception.DataException: could not execute query
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.DataException: could not execute query at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:616) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:378) at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:847) at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:843)
Name and version of the database you are using:
PostgreSQL 8.x
The generated SQL (show_sql=true):
2008-04-04 20:51:25,171 DEBUG [http-80-Processor25] HqlSqlWalker.processQuery(509) | processQuery() : ( SELECT ( {select clause} entry0_.id ) ( FromClause{level=1} ( ilc_entry entry0_ ilc_address addresses1_ ( ilc_review reviews2_ ilc_review_images imagestub4_ ) ) ) ( where ( = ( entry0_.id entry0_.id id ) ? ) ) )
Hibernate:
/* select
e
from
Entry e
left join
fetch e.addresses a
left join
fetch e.reviews r
left join
fetch r.images i
where
e.id = ? */ select
entry0_.id as id19_0_,
addresses1_.id as id14_1_,
reviews2_.id as id17_2_,
imagestub4_.id as id2_3_,
entry0_.name as name19_0_,
entry0_.description as descript3_19_0_,
entry0_.web_site as web4_19_0_,
entry0_.email as email19_0_,
entry0_.by_owner as by6_19_0_,
entry0_.entry_state as entry7_19_0_,
entry0_.created as created19_0_,
entry0_.ip as ip19_0_,
entry0_.POSTER_ID as POSTER10_19_0_,
entry0_.image_id as image11_19_0_,
addresses1_.phone_number as phone2_14_1_,
addresses1_.building_number as building3_14_1_,
addresses1_.STREET as STREET14_1_,
addresses1_.POSTALCODE as POSTALCODE14_1_,
addresses1_.CITY as CITY14_1_,
addresses1_.province as province14_1_,
addresses1_.country as country14_1_,
addresses1_.CITY_CODE as CITY9_14_1_,
addresses1_.entry_id as entry10_14_1_,
addresses1_.entry_id as entry10_0__,
addresses1_.id as id0__,
reviews2_.subject as subject17_2_,
reviews2_.content as content17_2_,
reviews2_.postDate as postDate17_2_,
reviews2_.IPAddress as IPAddress17_2_,
reviews2_.entry_id as entry6_17_2_,
reviews2_.user_id as user7_17_2_,
reviews2_.replyto as replyto17_2_,
reviews2_.rating as rating17_2_,
reviews2_.entry_id as entry6_1__,
reviews2_.id as id1__,
imagestub4_.description as descript3_2_3_,
images3_.review_id as review1_2__,
images3_.image_id as image2_2__
from
ilc_entry entry0_
left outer join
ilc_address addresses1_
on entry0_.id=addresses1_.entry_id
left outer join
ilc_review reviews2_
on entry0_.id=reviews2_.entry_id
left outer join
ilc_review_images images3_
on reviews2_.id=images3_.review_id
left outer join
ilc_images imagestub4_
on images3_.image_id=imagestub4_.id
where
entry0_.id=?
2008-04-04 20:51:25,281 WARN [http-80-Processor25] JDBCExceptionReporter.logExceptions(77) | SQL Error: 0, SQLState: 22023
2008-04-04 20:51:25,296 ERROR [http-80-Processor25] JDBCExceptionReporter.logExceptions(78) | No value specified for parameter 2.
|