Hibernate version:3.0
When I use the following query:
select myObj.name, count(*), Min(myObj.data), Max(myObj.date) from MyObjectClass myObj ....
I get an array of Object, everything is fine.
I can even check that I get an array of object and the first onject is of type String,
the second of type Integer and the last 2 of type Timestamp.
The following query is working just fine as well:
select new MyClass(myObj.name, ... , myObj.date) from MyObjectClass myObj ....
MyClass class having the right constructor
Now when I try the following query:
select new MyClass(myObj.name, ... , count(*), Min(myObj.data), Max(myObj.date)) from MyObjectClass myObj ....
I get 2 types of errors depending on the constructor:
if the constructor is
public MyClass(String name, Object numberOfItem, Object dateFrom, Object dateUntil) {...}
I get the error "could not instantiate: class MyClass"
if the constructor is
public MyClass(String name, Integer numberOfItem, Timestamp dateFrom, Timestamp dateUntil) {...}
I get the error "org.hibernate.PropertyNotFoundException: no appropriate constructor in class: MyClass"
My problem starts when I have aggregate functions. Is there any restriction in the use of typesafe Java object
in the query?
Any hint is welcome.
Thanks,
Richard
|