3

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.

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Wow, really? I guess it was my mistake to presume that such a widely used library used semantic version numbering. Without that, then perhaps the docs should be a little more informative on when new features were put in place.
H2 never had semantic versions, the releases are simply named sequentially.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.