如何使用 Hibernate Tools 执行 JPQL 查询?

发布于 2024-12-12 20:16:14 字数 1319 浏览 2 评论 0原文

我需要使用 JPQL 进行一些测试,因此我尝试使用 Hibernate Tools 进行测试,但是当我尝试打开会话工厂时出现以下内容: 无法找到 TransactionManager 如下所示:

在此处输入图像描述

这是我的 persistence.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="SuaParte">
        <jta-data-source>jdbc/suaparte_ds</jta-data-source>
        <class>entity.Area</class>
            //classes..
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
            <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
            <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
            <property name="hibernate.connection.datasource" value="jdbc/suaparte_ds"/>
        </properties>
    </persistence-unit>
</persistence>

I need to make some tests with JPQL, so I'm trying do that with Hibernate Tools, but when I try open the session factory appears this : Could not locate TransactionManager as showed below:

enter image description here

Here is my persistence.xml file

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="SuaParte">
        <jta-data-source>jdbc/suaparte_ds</jta-data-source>
        <class>entity.Area</class>
            //classes..
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
            <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
            <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
            <property name="hibernate.connection.datasource" value="jdbc/suaparte_ds"/>
        </properties>
    </persistence-unit>
</persistence>

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

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

发布评论

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

评论(1

南…巷孤猫 2024-12-19 20:16:14

我遇到了同样的问题,经过长时间寻找解决方案,我找到了一份出版物。

我尝试了链接 Hibernate 工具:找不到数据源 中给出的建议工作了。

I had the same problem and after a long search for solution I found one publication.

I tried the advice given in the link Hibernate tools: Could not find datasource and it worked.

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