I am trying to perform sanity check on db2 database, so I wrote:
Session session = _sessionFactory.openSession();
try{
return session.createNativeQuery("SELECT CURRENT DATE from sysibm.sysdummy1", Date.class)
.stream().findFirst().orElse(null);
}
catch (Exception e){
session.close();
throw e;
}
Where Date
is of type java.sql.Date
.
I even tried to add this node to hibernate.cfg.xml
file:
<mapping class="java.sql.Date"/>
Query itself works fine and returns "column" tagged as "1" with single row with date in yyyy-MM-dd format.
However when I execute the code I get error:
org.hibernate.MappingException: Unknown entity: java.sql.Date
Do I miss something?