-->
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.  [ 4 posts ] 
Author Message
 Post subject: What's wrong with my mapping file?
PostPosted: Tue Jan 11, 2005 6:41 pm 
Newbie

Joined: Tue Jan 11, 2005 6:38 pm
Posts: 5
I'm kind of new to Hibernate, and I'm using the eclipse plugin Syncrhonizer to generate the mapping files. Unfortunately when I run a simple JUnit test I get this:

[INFO] Environment - Hibernate 2.1.7
[INFO] Environment - hibernate.properties not found
[INFO] Environment - using CGLIB reflection optimizer
[INFO] Environment - JVM does not support Statement.getGeneratedKeys()
[INFO] Environment - JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled
[INFO] Environment - using workaround for JVM bug in java.sql.Timestamp
[INFO] Configuration - configuring from resource: /hibernate.cfg.xml
[INFO] Configuration - Configuration resource: /hibernate.cfg.xml
[INFO] Configuration - Mapping resource: Ddtemplate.hbm
[ERROR] XMLHelper - Error parsing XML: XML InputStream(71) The content of element type "class" must match "(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))".
net.sf.hibernate.MappingException: Error reading resource: Ddtemplate.hbm
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:888)
at com.jegs.commerce.support.data.base._BaseRootDAO.initialize(_BaseRootDAO.java:50)
at com.jegs.commerce.support.data.base._BaseRootDAO.initialize(_BaseRootDAO.java:37)
at com.jegs.commerce.support.facade.PartSelector.<init>(PartSelector.java:32)
at com.jegs.commerce.support.test.PartSelectorTest.testGetAllCategories(PartSelectorTest.java:30)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
... 20 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))".
at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1235)
at org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1781)
at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1425)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1216)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:383)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1120)
at org.dom4j.io.SAXReader.read(SAXReader.java:334)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:286)
... 21 more

My cfg file has this in it:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory name="iSeriesCommerce">
<!-- datasource connection properties -->
<property name="connection.datasource">CommerceDB</property>
<property name="hibernate.jndi.url">jdbc/commercedb</property>
<!-- dialect for DB2 -->
<property name="dialect">
net.sf.hibernate.dialect.DB2Dialect
</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.WebSphereTransactionManagerLookup
</property>
<property name="jta.UserTransaction">
java:comp/UserTransaction
</property>
<!-- Mapping files -->
<mapping resource="Ddtemplate.hbm" />
</session-factory>
</hibernate-configuration>

And my Ddtemplate.hbm has this:

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

<hibernate-mapping package="com.jegs.commerce.support.data">
<class name="Ddtemplate" table="DDTEMPLATE">
<property
column="TPPARENT"
length="10"
name="Tpparent"
not-null="true"
type="integer"
/>
<property
column="TPVAR08"
length="64"
name="Tpvar08"
not-null="true"
type="string"
/>
<property
column="TPVAR07"
length="64"
name="Tpvar07"
not-null="true"
type="string"
/>
<property
column="TPVAR06"
length="64"
name="Tpvar06"
not-null="true"
type="string"
/>
<property
column="TPVAR05"
length="64"
name="Tpvar05"
not-null="true"
type="string"
/>
<property
column="TPVAR04"
length="64"
name="Tpvar04"
not-null="true"
type="string"
/>
<property
column="TPVAR03"
length="64"
name="Tpvar03"
not-null="true"
type="string"
/>
<property
column="TPVAR02"
length="64"
name="Tpvar02"
not-null="true"
type="string"
/>
<property
column="TPVAR01"
length="64"
name="Tpvar01"
not-null="true"
type="string"
/>
</class>
<query name="AllResults">
<![CDATA[
from Ddtemplate as Ddtemplate
]]>
</query>
<query name="CategoryLookup">
<![CDATA[
from Ddtemplate as Ddtemplate where Tpparent = :parent
]]>
</query>
</hibernate-mapping>


What am I doing wrong?

Hibernate version: 2.1.7

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: IBM DB2 (running on AS/400)

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 6:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
your class doesn't have an id - probably because your table does not have a primary key.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Yep
PostPosted: Tue Jan 11, 2005 7:09 pm 
Newbie

Joined: Tue Jan 11, 2005 6:38 pm
Posts: 5
Yes, these tables are on an AS/400 and none of them have primary keys. I cannot change the way the table is setup.

Do I need to manually add an id property or is there a way to go without one?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 3:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hibernate needs to know which columns should be used to identify your entities n the tables.

I don't think Hibernate Synchronizer support this out of the box so you probably have to edit the generated hbm.xml's by hand.

you can go to the Hibernate Synchronizer forums to seek specific help for that tool.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.