Hi,
I'm using H2 embedded in my java server app. I'm using spring with Hibernate 4.3.6Final.
Some part of hibernate configuration:
Code:
<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"
destroy-method="close" lazy-init="true">
<!-- H2 -->
<property name="driverClassName" value="org.h2.Driver" />
<property name="url"
value="jdbc:h2:~/db/test;IFEXISTS=FALSE;AUTO_RECONNECT=TRUE" />
...
...
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="true" />
<!-- H2 -->
<property name="databasePlatform" value="org.hibernate.dialect.H2Dialect" />
</bean>
</property>
Unfortunally when I do this typed query:
Code:
String sql = "SELECT msg.id FROM Campagna c LEFT JOIN c.listaComunicazioni msg WHERE (msg.statoTelefonata=:statoTelefonata AND msg.preferenzaTelefonata <> :preferenzaTelefonata) OR (msg.statoSms=:statoSms AND msg.preferenzaSms <> :preferenzaSms) OR (msg.statoEmail=:statoEmail AND msg.preferenzaEmail <> :preferenzaEmail) AND DATE(dataProgrammata)<=DATE(NOW()) ORDER BY msg.tentativiTelefonata ASC";
TypedQuery<Long> query = entityManager.createQuery(sql, Long.class);
I've this exception in H2:
Code:
24/07/2014 09:36:30 ERROR SqlExceptionHelper:146 - Function "DATE" not found; SQL statement:
select comunicazi2_.id as col_0_0_ from Campagna campagna0_ left outer join Campagna_Comunicazione listacomun1_ on campagna0_.id=listacomun1_.Campagna_id left outer join Comunicazione comunicazi2_ on listacomun1_.listaComunicazioni_id=comunicazi2_.id where comunicazi2_.statoTelefonata=? and comunicazi2_.preferenzaTelefonata<>? or comunicazi2_.statoSms=? and comunicazi2_.preferenzaSms<>? or comunicazi2_.statoEmail=? and comunicazi2_.preferenzaEmail<>? and DATE(dataProgrammata)<=DATE(now()) order by comunicazi2_.tentativiTelefonata ASC [90022-180]
I opened a post in H2 forum https://groups.google.com/forum/#!topic/h2-database/I7GuYj-Bw4Y and they suggest me to post here the problem because maybe is an issue.
Thanks