質問

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?

役に立ちましたか?

解決

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.

他のヒント

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.

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top