Named Query DAO methods with Primitive types fail to compile with JDK 1.4

Description

This is the same issue as HBX-469, but I was asked to create a new case and attach my test case. Please see attached Eclipse/Maven project.

The problem is that if a named query with a type of "java.lang.Long" or "java.lang.Integer" exists in an HBM file, then the Hbm2Dao task converts it to a primitive long. This causes the compile to fail if you are using JDK 1.4.

For example:

<query name="findBySomeLong">
<query-param name="someLong" type="java.lang.Long" />
from Hbx469 where someLong=:someLong
</query>

when run through hbm2dao generates the following code:

public List findBySomeLong(long someLong) {
Query query = sessionFactory.getCurrentSession()
.getNamedQuery("Hbx469.findBySomeLong");
query.setParameter("someLong", someLong);
return query.list();
}

You will get a compile error on query.setParameter() when using JDK 1.4 because the java.lang.Long has been generated as a Java primitive long.

Environment

None

Attachments

2

Activity

Show:

Koen Aers December 9, 2024 at 2:48 PM

I am closing this issue as it did not have any relevant updates since 2008. Please feel free to reopen it if you think it is still relevant.

Max Rydahl Andersen July 21, 2008 at 3:30 PM

the labs.jboss.com was deprecated. use http://anonsvn.jboss.org/repos/hibernate/ i'll update the wiki page asap.

Joe Porcheddu July 18, 2008 at 3:16 PM

I would like to contribute this fix myself, but can't seem to get access to the Hibernate SVN repository following the documentation on http://www.hibernate.org/268.html.

Quite simply, when I try to connect to the SVN repository at http://anonhibernate.labs.jboss.com/branches/Branch_3_2/HibernateExt , it asks for a user name and password. How can I get credentials to contribute to this project?

Max Rydahl Andersen June 13, 2008 at 10:51 AM

for those who would like to fix this it should just be a matter of updating public String asFinderArgumentList(Map parameterTypes, ImportContext ctx) to have a jdk5 booelan parameter to distinguish between which kind of types to use....or maybe we should just pass through the actual type name if it is not a hibernate shorthand...

Max Rydahl Andersen June 13, 2008 at 10:44 AM

yes this is still broken ;(

Won't Fix

Details

Assignee

Reporter

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

Joe Porcheddu
Koen Aers
Max Rydahl Andersen

Community Help Wanted

Yes, please

Components

Fix versions

Affects versions

Priority

Created June 10, 2008 at 6:53 PM
Updated December 9, 2024 at 2:48 PM
Resolved December 9, 2024 at 2:48 PM