Hi,
I'd like to run a hql query with dynamic instantiation + unlimited arguments in the constructor. Therefor I created a class with a constructor with dynamic arguments:
Code:
public class MyClass {
public MyClass(Object... obj) {
// some code
}
}
However ... hibernate can't instantiate this class because he can't find the right constructor.
Can anyone tell me whether this is possible ?
Details:
Hibernate version: 3.0.0
Full stack trace of any exception that occurs:Caused by: org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [be.retailability.tellit.selector.oasis.lifesearch.LiveSearchStringArray] [select new be.retailability.tellit.selector.oasis.lifesearch.LiveSearchStringArray(hobj.voornaam,hobj.naam,hobj.rijksregisterNummer) from be.ugent.oasis.model.administratie.Persoon hobj where upper(naam) like '%DE B%' order by hobj.voornaam,hobj.naam,hobj.rijksregisterNummer]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:235)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1199)
at $Proxy41.createQuery(Unknown Source)
at be.retailability.util.hibernate.HibernateQueryCallbackFactoryImpl$LiveSearchCallback.doInHibernate(HibernateQueryCallbackFactoryImpl.java:301)
at be.retailability.util.hibernate.HibernateQueryCallbackFactoryImpl$LoggingCallback.doInHibernate(HibernateQueryCallbackFactoryImpl.java:140)
... 33 more
Name and version of the database you are using: Mysql 5
Debug level Hibernate log excerpt: debug
[/code]