java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [test.dto.EmployeeDto] [SELECT new test.dto.EmployeeDto(e.name, e.lastUpdated) FROM test.entities.Employee e ORDER BY e.name]

Hibernate JIRA | Bjorn Beskow | 8 years ago
  1. 0

    When a constructor JPQL query projects a Timestamp, it causes an org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor. For example, given the following Entity: @Entity public class Employee { ... private Timestamp lastUpdatedAsTimestamp; ... } and the following Pojo for the constructor query: public EmployeeDto(String name, Timestamp lastUpdated) {...} the following query will throw an exception: String query = "SELECT new test.dto.EmployeeDtoUsingTimestamp(e.name, e.lastUpdatedAsTimestamp) " + "FROM Employee e ORDER BY e.name"; List<EmployeeDto> reportList = em.createQuery(query).getResultList(); java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [test.dto.EmployeeDto] [SELECT new test.dto.EmployeeDto(e.name, e.lastUpdated) FROM test.entities.Employee e ORDER BY e.name] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:601) at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96) at test.ConstructorQueryTest.testEmployeesQuery(ConstructorQueryTest.java:63) ... This problem has been reported before (see HHH-278), but the workaround is not a portable JPA solution (having the type Timestamp in the Entity and the type Date in the Pojo constructor is not in line with the Spec, and does not work in other JPA implementations). I have attached a minimal Maven project with a test case which highlights the problem.

    Hibernate JIRA | 8 years ago | Bjorn Beskow
    java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [test.dto.EmployeeDto] [SELECT new test.dto.EmployeeDto(e.name, e.lastUpdated) FROM test.entities.Employee e ORDER BY e.name]
  2. 0

    When a constructor JPQL query projects a Timestamp, it causes an org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor. For example, given the following Entity: @Entity public class Employee { ... private Timestamp lastUpdatedAsTimestamp; ... } and the following Pojo for the constructor query: public EmployeeDto(String name, Timestamp lastUpdated) {...} the following query will throw an exception: String query = "SELECT new test.dto.EmployeeDtoUsingTimestamp(e.name, e.lastUpdatedAsTimestamp) " + "FROM Employee e ORDER BY e.name"; List<EmployeeDto> reportList = em.createQuery(query).getResultList(); java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [test.dto.EmployeeDto] [SELECT new test.dto.EmployeeDto(e.name, e.lastUpdated) FROM test.entities.Employee e ORDER BY e.name] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:601) at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96) at test.ConstructorQueryTest.testEmployeesQuery(ConstructorQueryTest.java:63) ... This problem has been reported before (see HHH-278), but the workaround is not a portable JPA solution (having the type Timestamp in the Entity and the type Date in the Pojo constructor is not in line with the Spec, and does not work in other JPA implementations). I have attached a minimal Maven project with a test case which highlights the problem.

    Hibernate JIRA | 8 years ago | Bjorn Beskow
    java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [test.dto.EmployeeDto] [SELECT new test.dto.EmployeeDto(e.name, e.lastUpdated) FROM test.entities.Employee e ORDER BY e.name]
  3. 0

    org.hibernate.hql.ast.QuerySyntaxException with Hibernate

    Stack Overflow | 8 years ago | Tam
    java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: ApplPerfStats is not mapped [select count(c) from ApplPerfStats c]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Conception d’un client Eclipse RCP et serveur OSGI avec Spring DM [step19] | Angelo's Blog

    wordpress.com | 3 months ago
    java.lang.IllegalArgumentException: org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [select u from org.dynaresume.domain.User u]
  6. 0

    Client Read-Only lazy collection ... at a loss

    Google Groups | 6 years ago | LimeTwist
    java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: validations of: com.kadre.domain.candidate.profile.CandidateProfile [select e from com.kadre.domain.candidate.profile.CandidateProfile e left join fetch e.validations where e = :entity]

    1 unregistered visitors
    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. java.lang.IllegalArgumentException

      org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [test.dto.EmployeeDto] [SELECT new test.dto.EmployeeDto(e.name, e.lastUpdated) FROM test.entities.Employee e ORDER BY e.name]

      at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException()
    2. Hibernate EJB
      AbstractEntityManagerImpl.createQuery
      1. org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:601)
      2. org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96)
      2 frames
    3. test
      ConstructorQueryTest.testEmployeesQuery
      1. test.ConstructorQueryTest.testEmployeesQuery(ConstructorQueryTest.java:63)
      1 frame