jQuery in Action, 2nd edition*
The moose likes Object Relational Mapping and the fly likes Hibernate/Derby; error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate/Derby; error message "Cannot close a connection while a transaction is still active"" Watch "Hibernate/Derby; error message "Cannot close a connection while a transaction is still active"" New topic
Author

Hibernate/Derby; error message "Cannot close a connection while a transaction is still active"

Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
I am learning Hibernate, using Derby in server mode on a Win7 machine, developing with eclipse. Java 1.6, Hibernate 3.6, Derby 10.8.

I have written a simple Hibernate configuration and one annotation-mapped class, along with a basic DAO subclass and a class to create users in a user table. I have double-checked (at least) that I have the right schema name, and the record the program writes does actually go into the database. But I don't know where this error is coming from and I think I must have something slightly wrong because I don't see other people posting about it anywhere.

config file:



main class:


CreateUser:


User:



Dao:


and the error log:



It is a longer post than I'm used to making, but I don't think there's a much smaller hibernate example to be had.

I'm stumped. I've looked into stackoverflow, derby fora, hibernate fora, I've added the schema name that someone thought was necesssary, I've cut it down from the 4 classes it used to have mapped, I've made a lazy-init-of-static of the SessionFactory, I do not know what else to try. Does anyone have any knowledge or even suggestions?
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
It turns out that Hibernate makes a determination of whether to look up certain database information in the database metadata, and if it can't it can run into this bug/feature. In version 3.x of Hibernate, there is an unpublicized property hibernate.temp.use_jdbc_metadata_defaults which, when set to false in the hibernate configuration, bypasses the check and so doesn't run into this. It doesn't happen in version 4.

Now if I can just figure out where to download version 4 of Hibernate, or whether the "full text search" version they have on their sourceforge site IS version 4 of hibernate, I'll be all set.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate/Derby; error message "Cannot close a connection while a transaction is still active"