我在H2数据库中使用datediff()函数时遇到了问题。 这是查询
String FIND_WORK_UNIT_BY_PART_UUID_AND_STATUS = "select new com.altissia.erasmus.domain.WorkUnitCustomObject(workUnit.studyLg," + "(datediff(workUnit.endTime , workUnit.startTime))) from V2WorkUnit workUnit where workUnit.workUnitState.status = 'PENDING' and workUnit.part.uuid =:partUuid order by workUnit.studyLg";
List<WorkUnitCustomObject> workUnitWithLateDays = entityManeger .createQuery(FIND_WORK_UNIT_BY_PART_UUID_AND_STATUS).setParameter("partUuid", partUuid).getResultList();
以下是例外:
引起:org.h2.jdbc.JdbcSQLException:SQL语句中的语法错误“select v2workunit0_.study_lg as col_0_0_,datediff(v2workunit0_.end_time,v2workunit0_.start_time)[*]
以下是应用程序ymll文件中的JPA属性
jpa:
packages.to.scan: com.altissia.erasmus.domain
database-platform: org.hibernate.dialect.H2Dialect
connection.driver_class: org.h2.Driver
database: H2
openInView: false
show_sql: true
generate-ddl: true
hibernate:
ddl-auto: ""
naming-strategy: org.hibernate.cfg.EJB3NamingStrategy
properties:
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
提前谢谢