I have a Mysql table with DATE column , default '0000-00-00'. If I try to call, for instance,
em.find(MyTable.class,pk_value);
and it happens to be a record in database with default date value '0000-00-00', an exception is thrown(
"java.sql.SQLException: Value ... cannot be represented as java.sql.Date". The same error happens for DateTime columns with default '0000-00-00 00:00:00'.
Is it any way to tell EntityManager that such values are ok ?
Thanks.
views:
175answers:
2
+3
A:
What helps is setting JDBC driver's zeroDateTimeBehavior property to convertToNull.
See http://ondra.zizka.cz/stranky/programovani/java/index.texy (look for "SQLException for zero DATETIME or TIMESTAMP column? Use zeroDateTimeBehavior").
jdbc:mysql://localhost/test?zeroDateTimeBehavior=convertToNull
Ondra Žižka
2010-01-15 21:20:47
I'm sure it will work, but it may cause many side effects, so I'd rather not do it unless it is the only solution.
a1ex07
2010-01-15 22:42:17