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]

Hibernate JIRA | Adam Wozniak | 9 years ago
  1. 0

    Hello Here in the documentation to Hibernate Core: http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#queryhql-select ... 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

    Hibernate JIRA | 9 years ago | Adam Wozniak
    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]
  2. 0

    Hello Here in the documentation to Hibernate Core: http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#queryhql-select ... 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

    Hibernate JIRA | 9 years ago | Adam Wozniak
    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]
  3. 0

    wavemaker and postgressql 9.3

    Stack Overflow | 3 years ago | Patr56
    org.hibernate.hql.ast.QuerySyntaxException: unexpected token: > near line 1, column 11 [select js->'b' from com.bddb.data.Test _a where _a.id=:id ]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    How to write Order by expression in JPQL

    Stack Overflow | 6 years ago | Gaim
    org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: = near line 1, column 73 [SELECT a FROM cz.cvut.fel.sk.model.department.Article a ORDER BY ( a.id = :id ) DESC, a.id DESC]
  6. 0

    How to write inline view in HQL?

    Stack Overflow | 4 years ago | Kishan
    org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 7 [ from (select att.licenceNo license,driver.driverName drivername,att.present present from com.vms.dto.DriverAttendanceDTO att,com.vms.dto.DriverDetailsDTO driver where att.licenceNo=driver.licenceNo and att.recordStatus='A' and driver.recordStatus='A' )]

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. 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()
    2. Hibernate HQL/JP-QL Parser
      QuerySyntaxException.convert
      1. org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
      2. org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
      2 frames