Inner classes in methods cannot be used in select clause when with conjunction with
"typesafe Java object" mechanism
--------------------------------------------------------------------------------------------------------------------
Key: HHH-2754
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2754
Project: Hibernate3
Issue Type: New Feature
Affects Versions: 3.2.4.sp1
Reporter: Adam Wozniak
Hello
Here in the documentation to Hibernate Core:
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#queryhql-s...
... we have a following example:
select new Family(mother, mate, offspr)
from DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr
But this mechanism doesn't work when Family class is defined as inner class in a
method.
So when I wrote something like this:
void myBusinessMethod()
{
class Family3
{
private String rowid;
private long coId;
private int csSeqno;
public Family3()
{
//
}
@SuppressWarnings("unused")
public Family3(
final String rowid
, final long coId
, final int csSeqno
)
{
//System.out.println("ssss");
this.rowid = rowid;
this.coId = coId;
this.csSeqno = csSeqno;
}
}
... and within this method I'm trying to do this:
query = sess.createQuery(
"select new typesafe_Java_object.TypesafeJavaObjectEMRWTest$1Family3(t.id, t.coId,
t.csSeqno) from BSCSCgTaroptLog t");
list = query.list();
... then I'm slapped by a following exception:
org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on
class [typesafe_Java_object.TypesafeJavaObjectEMRWTest$1Family3] [select new
typesafe_Java_object.TypesafeJavaObjectEMRWTest$1Family3(t.id, t.coId, t.csSeqno) from
pl.capgemini.tme.bonobo.model.BSCSCgTaroptLog t]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
(...)
So the question is:
Is it possible to add another method to org.hibernate.Session:
public Query createQuery(String queryString, FactoryType
factoryToGenerateMyInnerEntities)
???
Why do I need such mechanism? I rewriting a legacy system (Oracle PL/SQL) and I have many
different HQL queries. To use "typesafe Java object" I must make my mediate
classes static. But then I would have a kind of class bloat. And this is the reason why I
would like to hide those classes and make them much more locally (for example inside my
one single java method).
Kind regards,
Adam Wozniak
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira