-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: version tag is not recognized in Hibernate configuration
PostPosted: Tue Aug 24, 2004 5:42 am 
Newbie

Joined: Tue Aug 24, 2004 5:37 am
Posts: 3
[b]Hibernate version:[/b]
2.1.4, 2.1.5
[b]Mapping documents:[/b]
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="com.decitte.user.model.UserEntity" table="USER_ENTITY">

<cache usage="read-write"/>

<version column="VERSION" name="version" unsaved-value="null"/>

<id name="id" unsaved-value="null" column="USER_ID">
<generator class="native" >
<param name="sequence">USER_ENTITY_SEQUENCE</param>
</generator>
</id>

<property name="name" column="NAME"/>
<property name="gender" column="GENDER"/>
<property name="status" column="STATUS"/>

<set name="roleList" table="USER_ROLE" cascade="none" inverse="false">
<cache usage="read-write"/>
<key column="USER_ID"/>
<many-to-many column="ROLE_ID" class="com.decitte.user.model.RoleEntity"/>
</set>

<!--
one-to-many relation inverse should always set to true;
(don't update relation using UPDATE... when delete)
cascade="all" will take care of children lifecycle and relationship as well.
-->
<set name="resourceList" cascade="all" inverse="true">
<cache usage="read-write"/>
<key column="USER_ID"/>
<one-to-many class="com.decitte.user.model.UserResourceRelation"/>
</set>

</class>
</hibernate-mapping>

[b]Code between sessionFactory.openSession() and session.close():[/b]
none.
[b]Full stack trace of any exception that occurs:[/b]

net.sf.hibernate.MappingException: Error reading resource: hibernate/UserEntity.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:990)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:946)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:874)
at com.decitte.dao.hibernate.HibernateControlHome.initFactory(HibernateControlHome.java:27)
at com.decitte.dao.DAOControlHome.init(DAOControlHome.java:41)
at com.decitte.dao.DAOHomeController.load(DAOHomeController.java:69)
at com.decitte.dao.DAOHomeController.getInstance(DAOHomeController.java:36)
at com.decitte.business.ControlManager.getControl(ControlManager.java:30)
at com.decitte.user.business.DBManager.clearDatabase(DBManager.java:223)
at com.decitte.user.business.resource.ResourceTest.suite(ResourceTest.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:364)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:398)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:284)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:333)
... 18 more
Caused by: org.xml.sax.SAXParseException: Element "class" does not allow "version" here.
at org.apache.crimson.parser.Parser2.error(Parser2.java:3354)
at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(ValidatingParser.java:349)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1497)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:283)
... 19 more
com.decitte.dao.DAOException: Error reading resource: hibernate/UserEntity.hbm.xml
at com.decitte.dao.hibernate.HibernateControlHome.initFactory(HibernateControlHome.java:31)
at com.decitte.dao.DAOControlHome.init(DAOControlHome.java:41)
at com.decitte.dao.DAOHomeController.load(DAOHomeController.java:69)
at com.decitte.dao.DAOHomeController.getInstance(DAOHomeController.java:36)
at com.decitte.business.ControlManager.getControl(ControlManager.java:30)
at com.decitte.user.business.DBManager.clearDatabase(DBManager.java:223)
at com.decitte.user.business.resource.ResourceTest.suite(ResourceTest.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:364)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:398)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
net.sf.hibernate.MappingException: Error reading resource: hibernate/UserEntity.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:990)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:946)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:874)
at com.decitte.dao.hibernate.HibernateControlHome.initFactory(HibernateControlHome.java:27)
at com.decitte.dao.DAOControlHome.init(DAOControlHome.java:41)
at com.decitte.dao.DAOHomeController.load(DAOHomeController.java:69)
at com.decitte.dao.DAOHomeController.getInstance(DAOHomeController.java:36)
at com.decitte.business.ControlManager.getControl(ControlManager.java:30)
at com.decitte.user.business.DBManager.createDatabase(DBManager.java:65)
at com.decitte.user.business.resource.ResourceTest.setUp(ResourceTest.java:36)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:284)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:333)
... 20 more
Caused by: org.xml.sax.SAXParseException: Element "class" does not allow "version" here.
at org.apache.crimson.parser.Parser2.error(Parser2.java:3354)
at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(ValidatingParser.java:349)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1497)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:283)
... 21 more

[b]Name and version of the database you are using:[/b]
PostgreSQL 8.0 beta

[b]Debug level Hibernate log excerpt:[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 24, 2004 8:00 am 
Newbie

Joined: Tue Aug 17, 2004 7:38 am
Posts: 12
Location: Z
Hi,

If I don't remember wrong, the "version" property mapping must come immediately after the "identifier" property. Change it.

Code:
<id name="id" unsaved-value="null" column="USER_ID">
<generator class="native" >
<param name="sequence">USER_ENTITY_SEQUENCE</param>
</generator>

<version column="VERSION" name="version" unsaved-value="null"/>


Bye,

Roque[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 24, 2004 10:40 pm 
Newbie

Joined: Tue Aug 24, 2004 5:37 am
Posts: 3
Hi rcnavarro,

Thank you a lot. It works now.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.