-
1. Re: Hibernate tools keeps lock on HSQLDB
maxandersen Mar 15, 2010 9:27 AM (in response to coenos)Does right clicking on the Hibernate Configuration and click Close help ?
The configuration should though not have *any* locks on the database unless you actually used the database - what steps did you do before the lock is there ?
Another culprit can be the DTP connection which you might have asked to connect on startup and then it would be holding a lock too.
-
2. Re: Hibernate tools keeps lock on HSQLDB
coenos Mar 15, 2010 12:23 PM (in response to maxandersen)Hi Max,
thanks for your reply.
Closing the connection does not release the lock. The problem occurs when I open the Hibernate Configuration, see picture. However, when I click on the database (+) to open and see which entities there are, I get the Exception. This is when I actually use the database.
org.hibernate.exception.JDBCConnectionException: Getting database metadata
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getMetaData(AbstractMetaDataDialect.java:64)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.caseForSearch(AbstractMetaDataDialect.java:163)
at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getTables(JDBCMetaDataDialect.java:22)
at org.hibernate.cfg.reveng.JDBCReader.processTables(JDBCReader.java:476)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:74)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:116)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:107)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:63)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:234)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.sql.SQLException: The database is already in use by another process: org.hsqldb.persist.NIOLockFile@7a80f893[file =C:\Apps\hsqldb_1_8_1_2\hsqldb\data\seamdemoDB.lck, exists=true, locked=false, valid=false, fl =null]: java.lang.Exception: checkHeartbeat(): lock file [C:\Apps\hsqldb_1_8_1_2\hsqldb\data\seamdemoDB.lck] is presumably locked by another process.
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
at org.hsqldb.jdbcDriver.connect(Unknown Source)
at org.hibernate.console.FakeDelegatingDriver.connect(FakeDelegatingDriver.java:40)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getConnection(AbstractMetaDataDialect.java:122)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getMetaData(AbstractMetaDataDialect.java:61)
... 11 moreThe lock is never released, even after closing or refreshing the configuration. The lock is only released after closing Eclipse. But even then the lck file is not removed, I need to remove it myself.
I am not using DTP, only JBoss tools (Hibernate tools, Seam tools explicitly).
I think Hibernate Tools is somehow not closing the connection to the DB after refreshing the Hibernate configuration, what do you think?
Thanks,Coen
-
3. Re: Hibernate tools keeps lock on HSQLDB
coenos Mar 15, 2010 12:32 PM (in response to coenos)Ok, just after posting my reply I saw that I can seta property to prevent the lock file from even being created.
hsqldb.lock_file=false
This fixes the problem also
Cheers,
Coenos
-
4. Re: Hibernate tools keeps lock on HSQLDB
dgolovin Mar 15, 2010 2:43 PM (in response to coenos)Another solution is starting HSQL in server mode like it is explained in this article How to Use HSQL Database With JBossTools Right Way. -
5. Re: Hibernate tools keeps lock on HSQLDB
coenos Mar 15, 2010 2:47 PM (in response to dgolovin)Hi Denis,
yes I saw that article, but my development environment is set up differently, I don't use DTP for instance.
And I had all of that stuff working with Oracle XE and Derby. Only with HSQLDB I had this locking issue.
Cheers,
Coenos
-
6. Re: Hibernate tools keeps lock on HSQLDB
dgolovin Mar 15, 2010 3:21 PM (in response to coenos)Your solution is good and simple I'll mention this in article for in process option.
I thought you can skip all environment settings explained in article and just update JDBC connection URL to one like jdbc:hsqldb:hsql://localhost:1701 then then start HSQL in server mode and there should be no problems with lock file anymore.