gsibley
unread,Jul 21, 2011, 9:33:40 AM7/21/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to H2 Database
Hi
I'm extracting data out of an Oracle database, using squirrel, and
inserting it into an 'in-memory' H2 database for my integration tests.
I'm using hibernate annotations and the 'hbm2ddl.auto' utility to
create the schema in the integration tests. I'm using Springs
SimpleJdbcTestUtils.executeSqlScript() method to execute the file of
insert statements. This all works fine except for when I insert data
for DATE fields. The date members in the hibernate classes are
specified as java Date types. e.g.
@Temporal(TemporalType.DATE)
@Column(name = "MY_DATE")
private Date myDate;
Here's a snippet of my insert ddl statement:-
INSERT INTO "MY_TABLE" (ID,MY_DATE) VALUES (1,{ts '2011-07-01
16:19:18.0'});
I get the following stack trace:-
Caused by: org.h2.jdbc.JdbcSQLException: Cannot parse "DATE" constant
"2011-07-01 16:19:18.0"; SQL statement:
Caused by: java.lang.NumberFormatException: For input string: "01
16:19:18.0"
The above works fine if I remove the time portion of the date.
Is there anyway that I can get the time portion recognised?
Regards
George