1

嗨,我有以下 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:无法在资源 hibernate.cfg.xml 中的第 4 行和第 26 列执行解组。消息:cvc-elt.1:找不到元素“休眠配置”的声明。在 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) at org.hibernate.service.ServiceRegistryBuilder.configure(ServiceRegistryBuilder.java:147) 原因:javax.xml.bind.UnmarshalException - 带有链接异常:[org.xml.sax.SAXParseException: cvc-elt. 1:找不到元素“休眠配置”的声明。]

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

怎么了?


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

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

1 回答 1

2

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

这仍在进行中。

在这里找到:http: //www.mail-archive.com/hibernate-dev@lists.jboss.org/msg06948.html

于 2011-12-10T19:36:05.477 回答