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>
</hibernat开发者_运维问答e-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
精彩评论