hibernate 4.0.0。使用hibernate.cfg.xml的CR4:org.hibernate.internal.util.config.ConfigurationException

时间:2011-10-04 03:47:28

标签: hibernate parsing marshalling hibernate.cfg.xml

您好我有以下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());
}

我正在使用hibernate 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()

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,邮件列表中的答案略有不满意:

  

这仍在进行中。

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