-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problem using the HQL "NEW" operator
PostPosted: Mon Jun 18, 2007 11:10 am 
Newbie

Joined: Fri Jun 15, 2007 5:52 am
Posts: 2
I'm using the latest version of JBoss (4.2.0GA, that one is bundled with Hibernate EntityManager 3.2.1.GA, Hibernate Annotations 3.2.1.GA, Hibernate 3.2.3) and I'm trying to use the "NEW" HQL operator. My query is:

Code:
SELECT NEW mypackage.ReportEntry(a.name,ca.name,cl.date,COUNT(*)) FROM Click cl JOIN cl.campaign ca JOIN ca.agency a WHERE a.name=:aname GROUP BY a.name,ca.name,cl.date

It fails execution with this error message:

Code:
org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [mypackage.ReportEntry] [SELECT NEW mypackage.ReportEntry(a.name,ca.name,cl.date,COUNT(*)) FROM mypackage.Click cl JOIN cl.campaign ca JOIN ca.agency a WHERE a.name=:aname GROUP BY a.name,ca.name,cl.date]

That's strange, because the somepackage.ReportEntry class has this constructor:

Code:
    public ReportEntry(String aName, String caName, java.sql.Date date, Long count) {
        super();
        ...
    }

I've tried retriving the type of the four elements retrieved by the query by executing the query without the NEW operator:

Code:
SELECT a.name,ca.name,cl.date,COUNT(*) FROM Click cl JOIN cl.campaign ca JOIN ca.agency a WHERE a.name=:aname GROUP BY a.name,ca.name,cl.date

and looking at the classes of the elements in the Object[] returned for each row. It says

Code:
java.lang.String
java.lang.String
java.sql.Date
java.lang.Long

These are exactly the types in my constructor. I suspect this is a bug in Hibernate. Can anyone shed light on this issue?

It seems other users have had similar issues although their solutions seems to be identical to mine,which doesn't work:

http://forum.hibernate.org/viewtopic.php?p=2330678
http://forum.hibernate.org/viewtopic.php?p=2343242


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 10:58 am 
Newbie

Joined: Fri Jun 15, 2007 5:52 am
Posts: 2
Since noone has helped me identifying the problem, I have debugged into Hibernate and found out that the problem is, that I'm using java.sql.Date instead of java.util.Date in the object.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.