Skip to content

Spring 4.3.2 HibernateTemplate#findByNamedQuery isn't compatible with Hibernate 5.0 [SPR-14676] #19240

Closed
@spring-projects-issues

Description

@spring-projects-issues

Steve Storey opened SPR-14676 and commented

https://github.com/spring-projects/spring-framework/blob/master/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java#L958 attempts to be compatible with Hibernate 5.x, but because it's compiled against 5.2, the compiler then requires that the runtime method return a org.hibernate.query.Query instance, and thus when running with standard Spring Boot 1.4 versions, you get:

java.lang.NoSuchMethodError: org.hibernate.Session.getNamedQuery(Ljava/lang/String;)Lorg/hibernate/query/Query;
        at org.springframework.orm.hibernate5.HibernateTemplate$32.doInHibernate(HibernateTemplate.java:958)
        at org.springframework.orm.hibernate5.HibernateTemplate$32.doInHibernate(HibernateTemplate.java:954)
        at org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:356)
        at org.springframework.orm.hibernate5.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:323)
        at org.springframework.orm.hibernate5.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:954)
        at example.HibernateTemplateBugTest.testFindByNamedQuery(HibernateTemplateBugTest.java:28)

in the attached reproduction test when run with simply

mvn clean test

If however, you override the standard Hibernate version to 5.2.2 then the test succeeds by running

mvn -Dhibernate.version=5.2.2.Final clean test

Affects: 4.3.2

Attachments:

Issue Links:

Referenced from: commits 12afc26, d631b4c

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions