Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error using JPA SELECT NEW with Timestamp on constructor

I have the following JPA Query:

SELECT NEW test.vo.HappyVO(o.acid, o.dest, o.dep, o.time) FROM HappyTable1 o

My HappyVO has the following constructor:

public HappyVO(String a, String b, String c, java.sql.Timestamp e)

When i run this query i get the following error:

 org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [test.vo.HappyVO]

if i change the constructor to

public HappyVO(String a, String b, String c, Object e)

the error doesn't occur and variable e is an instance of java.sql.Timestamp

Forgot to mention i'm using a MySQL database, and the column is of type timestamp and declared type of the time field in HappyTable1 is java.sql.Timestamp

like image 294
Nuno Furtado Avatar asked Oct 26 '25 07:10

Nuno Furtado


1 Answers

It looks a lot like this known Hibernate bug: https://hibernate.atlassian.net/browse/HHH-4179

The suggested workaround is to use a Date type in your POJO constructor.

like image 79
David Levesque Avatar answered Oct 27 '25 20:10

David Levesque