These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: HSQLDB identity column quirks - has anyone else seen these?
PostPosted: Thu Nov 06, 2003 10:08 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
I noticed a few small oddities in the way identity columns behave with HSQLDB, just thought I'd post them to see if anyone else has seen these particular behaviors:

* If the type of the id is 'long' and the generator class is 'native', SchemaExport tool will try to create a table with an IDENTITY column of type 'BIGINT'. HSQLDB doesn't seem to like this, so a worked around it by changing the data type to 'int'.

Didn't work:
<id name="thingId" type="long">
<generator class="native"/>
</id>

Worked:
<id name="thingId" type="int">
<generator class="native"/>
</id>

* After fixing the above error, Hibernate was throwing an exception at run time when committing a transaction containing a new object. The error message indicates that the id property was 'modified' from '0' to '0', a little confusing, as that indicates nothing has changed. The cause seems to be the fact that the data type of the property in the persisted object is different than that of the descriptor (long vs. int in this case).

Changing the type of the property in the persisted object fixed the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 06, 2003 10:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use a later HSQLDB, ie. the one that ships with Hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 12:20 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
gavin wrote:
Use a later HSQLDB, ie. the one that ships with Hibernate.


I was not able to find hsqldb in the binary distributions of Hibernate 2.0.3 or 2.1 beta 6, maybe I have missed something. I'll check in CVS. Anyway, I tried switching to HSQLDB 1.7.1a, which is the latest version from the HSQLDB site, but this did not change the behavior.

The descriptor has the following element:

<id name="thingId" type="long" unsaved-value="-2000" >
<generator class="native"/>
</id>

The persisted object is:

public class Thing
{
private long thingId;

public long getThingId() ....
public void setThingId(long thingId) ....
}

This generates the following DDL:

create table THINGS (
thingId BIGINT NOT NULL IDENTITY,
... blah blah blah ....
);

HSQLDB apparently doesn't like the way the 'thingId' column is defined, and responds with:

Wrong data type: THINGID in statement [ create table ... blah blah blah ...


Top
 Profile  
 
 Post subject: The version of HSQLDB in CVS worked
PostPosted: Fri Nov 07, 2003 12:32 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
Well, I guess hsqldb.jar is not in the binary distributions so that threw me off slightly. SchemaExport and my simple unit test work fine with the version of HSQLDB in the hibernate2/lib directory.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 12:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ah heh yeah my bad ... it doesn't actually ship with hibernate does it?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 7:00 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
Nope, it sure doesn't. :) I just triple checked to make sure.

What magic version of HSQLDB is in CVS, exactly? I was surprised when the version recommended on the HSQLDB page didn't work correctly. I'll do some more digging, as the version that ships (for real) with Jboss 2.3.1 doesn't work either.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 7:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I think its a version marked with an "M", iirc.


Top
 Profile  
 
 Post subject: Any Solution for this
PostPosted: Tue Apr 20, 2004 1:44 pm 
Newbie

Joined: Mon Mar 08, 2004 10:17 pm
Posts: 2
I got the same problem. Davis, Did u get it solved by getting a newer version. Can you tell me the version of hibernate which solved the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 7:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
This is a hsqldb problem, use the version of hsqldb in the /jdbc folder in the Hibernate cvs/source distribution. Will that ever get fixed in the hsqldb original distribution?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 10:48 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
No, I built HSQLDB from CVS and it worked fine.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 21, 2004 5:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Probably the "some bugs fixed" in the release notes of hsqldb 1.7.2 RC5


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.