I am doing a SELECT query, using a Hibernate native query, like below:
public List<SomeDTO> findDTOs() {
StringBuilder sql = new StringBuilder();
sql.append(" SELECT id as id, localDateColumn as date, ");
sql.append(" FROM t");
Query query = entityManager.createNativeQuery(sql.toString());
query.unwrap(SQLQuery.class)
.addScalar("id", StandardBasicTypes.LONG)
.addScalar("localDateColumn", DateType.INSTANCE)
.setResultTransformer(Transformers.aliasToBean(SomeDTO.class));
return query.getResultList();
}
I tried using StandardBasicTypes.DATE or DateType.INSTANCE which does not work. I know that it works fine to map java.sql.Types#DATE and java.util.Date.
I would like to know how would I map java.sql.Types#DATE to java.time.LocalDate.