chillworld
chillworld

Reputation: 4277

H2 DB with datetime2

I'm trying to set up an embedded database H2 in an project that I took over. Now we have an sql server with a column value type datetime2.

H2 can't create the column with type datetime2, if I change it to normal datetime then all goes correct but of course the project itself gives problems cause hibernate annotation is wrong because the DB column is a datetime2.

the code :

@Column(name = "LASTUPDATETIME", columnDefinition = "datetime2 DEFAULT CURRENT_TIMESTAMP")
private Timestamp timeStamp;

Can this be done with H2(changing annotation for testing or let H2 accept datetime2) or do I have to search for another embedded database?

Upvotes: 2

Views: 1999

Answers (3)

Matthew
Matthew

Reputation: 11347

Possibly tangential. DATETIME2 is supported in H2, but DATETIME2(7) (or any other precision value) is no longer working as-of H2 4.197.

Upvotes: 0

Thomas Mueller
Thomas Mueller

Reputation: 50097

The H2 database does not currently support the data type datetime2 (as of version 1.3.176). However, support for it was added to the trunk now and will be available in the next release.

So, if you want to use H2 now, then you would either use a newer version (you could build it yourself for example), or change to datetime until you are using a newer version.

Upvotes: 3

Ewald
Ewald

Reputation: 5751

The Java Date column type should work for you, datetime2 is a Microsoft specific data type. I've seamlessly migrated applications from MS SQL Server to H2 database before, I had to change the annotation of course, but calculations etc. were not affected.

Upvotes: 0

Related Questions