Hibernate version: 2.1.7c
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="test">
<class name="TempVersionTest" table="TEMP_VERSION_TEST">
<id
column="id"
name="id"
type="integer"
>
<generator class="assigned" />
</id>
<property
name="name"
type="java.lang.String"
column="NAME"
length="30"
/>
<version column="LOCK_NUM" name="lockNum" type="integer"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public static void main(String[] args) throws Exception {
String mappingFile = "TempVersionTest.hbm";
Configuration config = new Configuration();
config.addFile(mappingFile);
}
Full stack trace of any exception that occurs:
2005-01-19 19:49:10,279 INFO [net.sf.hibernate.cfg.Environment] Hibernate 2.1.7
2005-01-19 19:49:10,295 INFO [net.sf.hibernate.cfg.Environment] loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.EhCacheProvider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.Oracle9Dialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=dor_tip5, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:oracle:thin:@pxlqa-db:1521:indqadb, hibernate.connection.password=password, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
2005-01-19 19:49:10,342 INFO [net.sf.hibernate.cfg.Environment] using java.io streams to persist binary types
2005-01-19 19:49:10,342 INFO [net.sf.hibernate.cfg.Environment] using CGLIB reflection optimizer
2005-01-19 19:49:10,342 INFO [net.sf.hibernate.cfg.Environment] using JDK 1.4 java.sql.Timestamp handling
2005-01-19 19:49:10,357 INFO [net.sf.hibernate.cfg.Configuration] Mapping file: TempVersionTest.hbm
2005-01-19 19:49:10,857 DEBUG [net.sf.hibernate.util.DTDEntityResolver] trying to locate
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
2005-01-19 19:49:10,857 DEBUG [net.sf.hibernate.util.DTDEntityResolver] found
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
2005-01-19 19:49:11,076 ERROR [net.sf.hibernate.util.XMLHelper] Error parsing XML: TempVersionTest.hbm(21) 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*))".
2005-01-19 19:49:11,092 ERROR [net.sf.hibernate.cfg.Configuration] Could not configure datastore from file: TempVersionTest.hbm
net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:173)
at com.tpt.thresher.server.schedule.gas.core.helper.TestDTO.main(TestDTO.java:43)
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:1150)
at org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1742)
at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1383)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1260)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1035)
at org.dom4j.io.SAXReader.read(SAXReader.java:323)
at org.dom4j.io.SAXReader.read(SAXReader.java:218)
at org.dom4j.io.SAXReader.read(SAXReader.java:207)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:172)
... 1 more
net.sf.hibernate.MappingException: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:179)
at com.tpt.thresher.server.schedule.gas.core.helper.TestDTO.main(TestDTO.java:43)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:173)
... 1 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:1150)
at org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1742)
at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1383)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1260)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1035)
at org.dom4j.io.SAXReader.read(SAXReader.java:323)
at org.dom4j.io.SAXReader.read(SAXReader.java:218)
at org.dom4j.io.SAXReader.read(SAXReader.java:207)
at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:172)
... 1 more
Exception in thread "main"
Name and version of the database you are using: Oracle 9i
The generated SQL (show_sql=true): No session used. Getting a parsing exception
Debug level Hibernate log excerpt: Mentioned above
IDE Used: Eclipse
Hibernate throws a Mapping Exception if both the <version> and the <property> elements exist for the same class mapping.
However, if the <property> element is removed from the mapping, then no exception is thrown.
Why can't a mapping document contain both property and version?
Thanks,
Vishal