有关 OpenJPA 的 HSQLdb 权限

发布于 2024-09-03 22:32:25 字数 2096 浏览 2 评论 0原文

我(仍然)遇到了 HSQLdb 和 HSQLdb 的大量问题。打开JPA。

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)

HSQLdb 作为服务器进程运行,绑定到我本地计算机上的端口 9001。用户是SA。它的配置如下:

<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>

我已经与我的 ORM 层成功连接。我可以创建并连接到我的 EntityManager。

然而,每次我使用

EntityManagerHelper.commit();

它都会失败并出现该错误,这对我来说毫无意义。 SA 是我用来创建表的标准管理员用户。它应该能够作为该用户持久保存到 hsqldb 中。

编辑:经过几个小时的调试,我发现了失败的原因。如果您未设置所需的表条目(NOT NULL),也会出现此类错误消息。这对我来说并没有表明这一点。由于权限问题缺少条目,OpenJPA 层似乎错误地无法插入语句。因此我只是接受了第一个答案。感谢您的阅读:)

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 :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘亓 2024-09-10 22:32:25

我印象深刻的是 HSQL 无权在配置的目录中写入其数据文件。

当我以 root/管理员身份手动测试我的服务器时,这种情况经常发生在我身上,并且当我将其作为守护程序/服务启动时,它会更改为特权较低的用户。然后,当服务器运行时,这些文件由另一个用户拥有。

这可能是其他原因:在 Windows 上,当另一个进程(另一个服务器实例)仍然坚持文件时,或者甚至当 eclipse 以其无限的智慧决定对数据库建立索引时,我就遇到了它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文