Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

H2 Database error Unknown data type INTERVAL

Tags:

sql

jdbc

h2

I'm working on integration tests for a JPA project. The tests run on an embedded h2 database. However, I'm getting an error from h2 during hibernate schema generation when I use

@Column(columnDefinition = "INTERVAL HOUR TO MINUTE")

The error is org.h2.jdbc.JdbcSQLException: Unknown data type: "INTERVAL";

The h2 documentation indicates that INTERVAL is supported:

http://www.h2database.com/html/datatypes.html#interval_type

I am using h2 version 1.4.197

Stepping away from JPA and working directly in the h2 console, I have tried the following script which also generates the Unknown data type error:

CREATE TABLE test_interval (id INTEGER, test_hours INTERVAL HOUR TO MINUTE);

I have tried other variations of the INTERVAL type, all of which generate the same error

I can not find any discussion of this issue anywhere.

like image 770
jlar310 Avatar asked Mar 17 '26 10:03

jlar310


1 Answers

You need to use a more recent version of H2. H2 supports the standard INTERVAL data type since 1.4.198, but 1.4.198 is a beta-quality version, use a more recent one, such as 1.4.199 or 1.4.200.

The online documentation is actual only for the latest release, currently it is 1.4.200. If you use some older version, you have to use the documentation from its distribution.

like image 62
Evgenij Ryazanov Avatar answered Mar 19 '26 03:03

Evgenij Ryazanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!