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

查看:112
本文介绍了休眠4.0.0。 CR4:org.hibernate.internal.util.config.ConfigurationException与hibernate.cfg.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有以下hibernate.cfg.xml

 <?xml version =1.0encoding =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());

$ / code>

我正在使用hibernate 4.0.0.CR4
hsqldb p>

我得到这个错误。

org.hibernate.internal.util.config.ConfigurationException:无法在RESOURCE hibernate.cfg.xml的第4行和第26列执行解组。消息:cvc-elt.1:找不到元素'hibernate-configuration'的声明。
at org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:120)
at 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构建器。

 新的MetadataSources(new ServiceRegistryBuilder()
.configure()
.buildServiceRegistry())
.buildMetadata()。
buildSessionFactory()


解决方案

同样的问题和在邮件列表中发现的稍微不满意的答案是:


这仍在进行中。


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


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

解决方案

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/hibernate-dev@lists.jboss.org/msg06948.html

这篇关于休眠4.0.0。 CR4:org.hibernate.internal.util.config.ConfigurationException与hibernate.cfg.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆