views:

229

answers:

1

Hi!

I'm (still) having loads of issues with HSQLdb & OpenJPA.

Exception in thread "main" <openjpa-1.2.0-r422266:683325 fatal store error> org.apache.openjpa.persistence.RollbackException: user lacks privilege or object not found: OPENJPA_SEQUENCE_TABLE {SELECT SEQUENCE_VALUE FROM PUBLIC.OPENJPA_SEQUENCE_TABLE WHERE ID = ?} [code=-5501, state=42501]
    at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:523)
    at model_layer.EntityManagerHelper.commit(EntityManagerHelper.java:46)
    at HSQLdb_mvn_openJPA_autoTables.App.main(App.java:23)

The HSQLdb is running as a server process, bound to port 9001 at my local machine. The user is SA. It's configured as follows:

<persistence-unit name="HSQLdb_mvn_openJPA_autoTablesPU"
        transaction-type="RESOURCE_LOCAL">
        <provider>
            org.apache.openjpa.persistence.PersistenceProviderImpl
        </provider>
        <class>model_layer.Testobjekt</class>
        <class>model_layer.AbstractTestobjekt</class>
        <properties>
            <property name="openjpa.ConnectionUserName" value="SA" />
            <property name="openjpa.ConnectionPassword" value=""/>

            <property name="openjpa.ConnectionDriverName"
                value="org.hsqldb.jdbc.JDBCDriver" />
            <property name="openjpa.ConnectionURL"
                value="jdbc:hsqldb:hsql://localhost:9001/mydb" />

            <!-- 
            <property name="openjpa.jdbc.SynchronizeMappings"
                value="buildSchema(ForeignKeys=true)" />
                 -->
        </properties>
    </persistence-unit>

I have made a successful connection with my ORM layer. I can create and connect to my EntityManager.

However each time I use

EntityManagerHelper.commit();

It fail with that error, which makes no sense to me. SA is the Standard Admin user I used to create the table. It should be able to persist as this user into hsqldb.

edit: after hours of debugging I found out why this fails. This kind of error message also appears if you do not set required table entries (NOT NULL). It didn't indicate that for me. It seems the OpenJPA layer mistakes not being able to insert statements because of missing entries for permission problems. I simply accepted the first answer therefore. Thanks for reading :)

+1  A: 

I have the impressoin that HSQL has no rights to write its datafile in the configured directory.

That happens to me all the time when I test my server manually as root/Administrator and that when starting it as a daemon/service it changes to a less privileged user. Then the files are owned by another user as the server is running as.

It could be other reasons : on Windows I had it when another process (another server instance) was still clinging on to the files, or even when eclipse in its infinite wisdom decided to index the database.

Peter Tillemans
I changed the file permissions on my Linux box to 777, run it as the same user as Java and Eclipse - same error. Can't be a file-permission problem.
wishi
Maybe it is looking in the wrong place. HSQL will be regularly writing in its db files. You might check if the files in the data directory for your database are there and if they have a recent modification timestamps. If not maybe there is an issue with relative paths which are starting from a different application root than expected.
Peter Tillemans