I have a named query:
Code:
<named-native-query name="mynamednativesqlquery">
<query>
<![CDATA[
select a_string, b_string, c_timestamp from table_a
]]>
</query>
</named-native-query>
Then some code to execute:
Code:
Query query = entityManager .createNamedQuery("mynamednativesqlquery");
for (Object obj : query.getResultList()) {
value_a_string = (String) ((Object[]) obj)[0];
value_b_string = (String) ((Object[]) obj)[1];
value_c_timestamp = (Timestamp) ((Object[]) obj)[2];
}
When I run this, it casts an exception saying it cannot convert from String to Timestamp (value_c_timestamp).
How can I tell Hibernate that ((Object[]) obj)[2] actually is a timestamp column in the database?