休眠4.0.0。 CR4:org.hibernate.internal.util.config.ConfigurationException 与 hibernate.cfg.xml

发布于 2024-12-07 22:02:07 字数 2409 浏览 9 评论 0原文

嗨,我有以下 hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM 
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="myFactory">
    <property   name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property   name="hibernate.connection.url">jdbc:hsqldb:mem:EnumTypeTest</property>
    <property name="hibernate.connection.username">sa</property>
    <property   name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="hibernate.hbm2ddl.auto">create-drop</property>
    <property name="hibernate.connection.pool_size">10</property>
    <mapping resource="com/test/domain/DomainWithEnumInt.hbm.xml" />
</session-factory>
 </hibernate-configuration>

在我的测试中我有。

@Test
public void testWriteEnumWithInt() {
     this.sessionFactory = new Configuration()
            .buildSessionFactory(new       ServiceRegistryBuilder().configure().buildServiceRegistry());
    final DomainWithEnumInt dwei = new DomainWithEnumInt(EnumIntType.Two);
    this.sessionFactory.withOptions().save(dwei);
    Assert.assertNotNull(dwei.getId());
}

我正在使用休眠4.0.0.CR4 hsqldb

我收到此错误。

org.hibernate.internal.util.config.ConfigurationException:无法在 RESOURCE hibernate.cfg.xml 中的第 4 行和第 26 列处执行解组。消息:cvc-elt.1:找不到元素“hibernate-configuration”的声明。 在 org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:120) 在 org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:69) 在org.hibernate.service.ServiceRegistryBuilder.configure(ServiceRegistryBuilder.java:162) 在org.hibernate.service.ServiceRegistryBuilder.configure(ServiceRegistryBuilder.java:147) 引起原因:javax.xml.bind.UnmarshalException - 带有链接异常: [org.xml.sax.SAXParseException: cvc-elt.1: 找不到元素“hibernate-configuration”的声明。]

该代码可以在 hibernate 3.6 GA 中运行,但无法在 hibernate 4 上运行(忽略编译错误)。

怎么了?


抱歉还是不行。我什至尝试使用 MetaDataSources 构建器。

new MetadataSources(new ServiceRegistryBuilder()
                .configure()
                .buildServiceRegistry())
                .buildMetadata().
                buildSessionFactory()

Hi i have the following hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM 
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="myFactory">
    <property   name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property   name="hibernate.connection.url">jdbc:hsqldb:mem:EnumTypeTest</property>
    <property name="hibernate.connection.username">sa</property>
    <property   name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="hibernate.hbm2ddl.auto">create-drop</property>
    <property name="hibernate.connection.pool_size">10</property>
    <mapping resource="com/test/domain/DomainWithEnumInt.hbm.xml" />
</session-factory>
 </hibernate-configuration>

In my test i have.

@Test
public void testWriteEnumWithInt() {
     this.sessionFactory = new Configuration()
            .buildSessionFactory(new       ServiceRegistryBuilder().configure().buildServiceRegistry());
    final DomainWithEnumInt dwei = new DomainWithEnumInt(EnumIntType.Two);
    this.sessionFactory.withOptions().save(dwei);
    Assert.assertNotNull(dwei.getId());
}

I am using hibernate 4.0.0.CR4
hsqldb

I get this error.

org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 4 and column 26 in RESOURCE hibernate.cfg.xml. Message: cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.
at org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:120)
at org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:69)
at org.hibernate.service.ServiceRegistryBuilder.configure(ServiceRegistryBuilder.java:162)
at org.hibernate.service.ServiceRegistryBuilder.configure(ServiceRegistryBuilder.java:147)
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.]

the code works in hibernate 3.6 GA but fails to run on hibernate 4 (disregarding the compile error).

What is wrong?


Sorry still doesn't work. I even tried using MetaDataSources builder.

new MetadataSources(new ServiceRegistryBuilder()
                .configure()
                .buildServiceRegistry())
                .buildMetadata().
                buildSessionFactory()

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

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

发布评论

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

评论(1

猥琐帝 2024-12-14 22:02:07

我遇到了同样的问题,在邮件列表中找到的稍微不满意的答案是:

这项工作仍在进行中。

在这里找到:http://www.mail-archive。 com/[电子邮件受保护]/msg06948.html

I had the very same problem and the slightly unsatisfactory answer found in the mailing list is:

This is still work in progress.

Found here: http://www.mail-archive.com/[email protected]/msg06948.html

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