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:
|