Issue Details (XML | Word | Printable)

Key: HHH-3401
Type: Patch Patch
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Steve Ebersole
Reporter: Thomas Mueller
Votes: 23
Watchers: 19
Operations

If you were logged in you would be able to see more operations.
Hibernate Core

H2 Database Dialect Fixes

Created: 26/Jul/08 01:05 PM   Updated: 01/Jun/09 10:38 AM
Component/s: core
Affects Version/s: None
Fix Version/s: 3.2.7, 3.3.2, 3.5

Time Tracking:
Not Specified

File Attachments: 1. Java Source File H2Dialect.java (14 kB)
2. Text File H2Dialect.java.patch (2 kB)
3. Zip Archive test.zip (2 kB)



 Description  « Hide
There are a few bugs in the H2 Dialect:

- There is no native BIT data type in H2.
- The database function DATEDIFF does have parameters
- There is a typo in function QUARTER

I have created a patch and a simple test case: The problem with the BIT / BOOLEAN data type appears if you run the test twice. Please tell me if you need more information.

Regards,
Thomas

 All   Comments   Work Log   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Thomas Mueller added a comment - 26/Jul/08 01:14 PM
For convenience, here the patched H2Dialect file.

Martin Thelian added a comment - 14/Oct/08 09:19 AM
Any news on this topic? Thanks.

Loïc Lefèvre added a comment - 15/Dec/08 08:16 AM
As said by Martin, any news?

Chris Bredesen added a comment - 15/Dec/08 08:20 AM
Anyone looking for news should use the attached patch and report findings. Higher confidence == more likely to commit!

Ryan McKinley added a comment - 23/Dec/08 03:06 AM
i was able to successfully use h2 with hibernate using this patch

Endre Stølsvik added a comment - 15/Jan/09 07:10 PM
@Chris: You do realize that the reporter and patch-creator in question here, Thomas Mueller, is the _creator_ and developer of H2? And that his words and code thus are, in fact, The Truth?

How strange of Hibernate that when a developer of a product comes with a patch concerning the integration to /his own product/, it isn't pretty much just insta-included?!

Loïc Lefèvre added a comment - 16/Jan/09 03:07 AM
@Endre, good point! totally agree with you. I can't imagine the author submitting a wrong patch.

I even wonder if one day H2 will replace hsqldb inside JBoss AS...

Chris Bredesen added a comment - 26/Jan/09 01:42 PM
@Endre: I did not know this, so we'll definitely include the patch ASAP. I've always wondered why vendors that maintain/contribute Dialects just don't ship them with the JDBC driver (or with the whole database, in this case).

Chris Bredesen added a comment - 27/Jan/09 09:43 AM
I applied this patch to 3.3 and I get the same test results before and after - 17 errors, 3 failures. So perhaps we're missing some coverage. I'm interested in the test that fails when you run it twice. Can you shed some light on that? The test provided simply saves an instance that contains some basic columns (one being boolean). Certainly the 3.3 testsuite covers this. But we cannot rely on back-to-back runs to see a failure. Do you think you can conceive of a test that shows the error using a single run of the TS?

Thanks again for the contribution, Thomas!

Thomas Mueller added a comment - 30/Jan/09 04:54 PM
Hi Chris,

> we're missing some coverage

Yes, it looks like.

> Certainly the 3.3 testsuite covers this

Yes, but the testsuite doesn't seem to test 'reloading'. It is probably possible to test this feature, but I'm not familiar with the Hibernate test suite. If you want me to write a better test case then it would take some more time I'm afraid...

> why vendors that maintain/contribute Dialects just don't ship them

The dialect is included in H2 under h2/src/tools/org/hibernate/dialect/H2Dialect.java.txt (I renamed it to .txt so that I don't have to add a dependency to Hibernate). I could include the class file in the h2*.jar, but that would not help if the Hibernate jar file is loaded first. Also, writing a dialect that works with all versions of Hibernate could be hard.

Regards,
Thomas

Steve Ebersole added a comment - 23/Mar/09 11:02 AM
Thomas, what's the nature of this "problem with the BIT / BOOLEAN data type"?

Thomas Mueller added a comment - 24/Mar/09 09:32 AM
For H2, BIT and BOOLEAN are the same data type. The same as CHAR and CHARACTER are the same data type. If you create a table like this:

CREATE TABLE TEST(B BIT, C CHARACTER);

and then retrieve the meta data (using DatabaseMetaData) and re-construct the CREATE TABLE statement you get:

CREATE TABLE TEST(B BOOLEAN, C CHAR);

However Hibernate doesn't 'know' currently that BIT is BOOLEAN is the same, because of the H2Dialect. So when you start the test again, Hibernate says that the data type BOOLEAN is not compatible with BIT.

By the way this problem was found by Dan Allen. He works for Red Hat / JBoss now. See also http://www.manning-sandbox.com/thread.jspa?threadID=26080&tstart=0

Please tell me if you have more question.

Lars Helge Øverland added a comment - 04/Apr/09 06:28 AM
A work-around while waiting for the patch to be incorporated in Hibernate would simply be to include this patch in your own application, then change the hibernate.dialect property accordingly. Hibernate would not load this class until the Hibernate configuration is assembled in your application.

Oleksandr Maksymchuk added a comment - 04/Apr/09 11:44 AM
If it is okay, why don't you apply it?
Need to wait one more year?

Steve Ebersole added a comment - 01/Jun/09 10:38 AM
Applied; thanks Thomas.