Hello: I want to run a native SQL query and map each row to an instance of a custom class (the "result-class", from now on). To do that, I'm using a mapping file in XML, not annotations (just in case it's relevant). One of the columns of the query is being formatted, explicitly, as a "java.sql.Timestamp". The result-class has a single constructor, one of its arguments is of type "java.sql.Timestamp" too, and it's in the proper position. But Hibernate throws the following exception:
To find out the origin of this error, I've reduced my case to the minimum expression. Now I'm running a query with a single column. And the constructor of the result-class only receives 1 argument, of the same type that the column's: "java.sql.Timestamp".
public final ProductOrder {
public ProductOrder (java.sql.Timestamp deliveryTime) {
...
}
}
SELECT product_order.delivery_time
FROM product_order
<sql-result-set-mapping name="Order">
<constructor-result target-class="my.company.ProductOrder">
<column name="delivery_time" class="java.sql.Timestamp"/>
</constructor-result>
</sql-result-set-mapping>
But Hibernate keeps throwing the exception. The only way that I've found to make it work has been modifying the result-class to receive a "java.lang.Date" instead. Although I've kept the explicit formatting to "java.lang.Timestamp" in the XML file. May it be a bug? Shouldn't Hibernate look for a constructor that uses an argument of type "java.sql.Timestamp" instead of "java.lang.Date"? This same error occurs with the types "java.sql.Date" and "java.sql.Time". Thank you. |