-->
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: Bad mapping?! How so?
PostPosted: Thu May 03, 2007 4:55 pm 
Beginner
Beginner

Joined: Tue Jul 25, 2006 12:34 pm
Posts: 25
Hibernate version: 3.x

The mapping doc below works just fine. That is, it did before I added the sql-insert, -update, -delete statements. Now it won't even compile. I keep getting:

Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:463)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:520)
... 143 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),
discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|
component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,
((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,
filter*,resultset*,(query|sql-query)*)".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

The XML validator in Eclipse is also repeating the content error. I've moved the statements after the list; tried it outside the <class> tag.

What's wrong with the file?


Mapping documents:

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

<hibernate-mapping default-cascade="none" default-access="property" auto-import="true"
package="us.tx.state.oag.FinancialCrimesInquiry.db.userSelects">

<class name="HbmUserSelectStatements" table="info_user_select_statements">

<id name="SelectId" column="select_id" type="long">
<generator class="identity"/>
</id>

<property name="UserId" column="user_id" type="string" length="12" not-null="true" update="true" insert="true"/>
<property name="Name" column="select_name" type="string" length="60" not-null="true" update="true" insert="true"/>
<property name="DateCreated" column="date_created" type="timestamp" length="23" not-null="true" update="true" insert="true"/>
<property name="Description" column="description" type="string" update="true" insert="true"/>
<property name="IsDisabled" column="is_disabled" type="int" update="true" insert="true"/>
<property name="IsPublic" column="is_public" type="int" update="true" insert="true"/>

<sql-insert callable="true">{ ? = call info_user_select_statements_spa (?,?,?,?,?,?,?) }</sql-insert>
<sql-delete callable="true">{ ? = call info_user_select_statements_spd (?) }</sql-delete>
<sql-update callable="true">{ ? = call info_user_select_statements_spu (?,?,?,?,?,?,?) }</sql-update>

<list name="SelectFields" inverse="true" lazy="false" cascade="all">
<key column="select_id" not-null="true"/>
<index column="select_field_id"/>
<one-to-many class="HbmUserSelectFields"/>
</list>

</class>

<sql-query name="info_user_selects_list_spr" callable="true">
<return alias="hbmUserSelectStatements" class="HbmUserSelectStatements"/>
<![CDATA[
{ call info_user_selects_list_spr(?) }
]]>
</sql-query>

<sql-query name="info_user_select_statements_spr" callable="true">
<return alias="hbmUserSelectStatements" class="HbmUserSelectStatements"/>
<![CDATA[
{ call info_user_select_statements_spr(?) }
]]>
</sql-query>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 12:52 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
Place the
<list>...</list>
element above,
<sql-insert>....</sql-insert>
....
<sql-delete>...</sql-delete
>
It should work fine.
Here's an extract from DTD.
<!ELEMENT class (
meta*,
subselect?,
cache?,
synchronize*,
comment?,
tuplizer*,
(id|composite-id),
discriminator?,
natural-id?,
(version|timestamp)?,
(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,
((join*,subclass*)|joined-subclass*|union-subclass*),
loader?,sql-insert?,sql-update?,sql-delete?,
filter*,
resultset*,
(query|sql-query)*
)>


------------------------------------------------------
Rate the reply if you find it helpful


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 9:10 am 
Beginner
Beginner

Joined: Tue Jul 25, 2006 12:34 pm
Posts: 25
Thought the same thing. Two different XML editors in Eclipse give the same error (below). Could my reference to the DTD be wrong? Is the editor using the one from the Web instead of the local jar? If I'm on Hibernate 3.2.x, why hasn't the DTD been updated since 3.0? Surely something's changed in it since 3.0?

Editor Error

Code:
Severity and Description   Path   Resource   Location   Creation Time   Id
The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".   FinancialCrimesInquiry/src/us/tx/state/oag/FinancialCrimesInquiry/db/userSelects   HbmUserSelectStatements.hbm.xml   line 8   1178283600265   86332


And JBoss doesn't like it either:

Code:
08:05:13,937 ERROR [XMLHelper] Error parsing XML: XML InputStream(31) The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
08:05:13,937 ERROR [[/FinancialCrimesInquiry]] Exception sending context initialized event to listener instance of class us.tx.state.oag.FinancialCrimesInquiry.ContextListener
org.hibernate.InvalidMappingException: Could not parse mapping document from resource us/tx/state/oag/FinancialCrimesInquiry/db/userSelects/HbmUserSelectStatements.hbm.xml
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
   at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
   at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
   at us.tx.state.oag.FinancialCrimesInquiry.ContextListener.contextInitialized(ContextListener.java:52)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3763)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211)
...
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:502)
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
   ... 143 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
   at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
   at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
   at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
   at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
   at org.dom4j.io.SAXReader.read(SAXReader.java:465)
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:499)
   ... 144 more



Updated hbm.xml file

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

<hibernate-mapping default-cascade="none" default-access="property" auto-import="true"
   package="us.tx.state.oag.FinancialCrimesInquiry.db.userSelects">

    <class name="HbmUserSelectStatements" table="info_user_select_statements">
       
      <id name="SelectId" column="select_id" type="long">
         <generator class="identity"/>
      </id>
      
      <property name="UserId" column="user_id" type="string" length="12" not-null="true" update="true" insert="true"/>
      <property name="Name" column="select_name" type="string" length="60" not-null="true" update="true" insert="true"/>
      <property name="DateCreated" column="date_created" type="timestamp" length="23" not-null="true" update="true" insert="true"/>
      <property name="Description" column="description" type="string" update="true" insert="true"/>
      <property name="IsDisabled" column="is_disabled" type="int" update="true" insert="true"/>
      <property name="IsPublic" column="is_public" type="int" update="true" insert="true"/>

      <list name="SelectFields" inverse="true" lazy="false" cascade="all">
         <key column="select_id" not-null="true"/>
         <index column="select_field_id"/>
         <one-to-many class="HbmUserSelectFields"/>
      </list>

       <sql-insert callable="true">{ ? = call info_user_select_statements_spa (?,?,?,?,?,?,?) }</sql-insert>
       <sql-delete callable="true">{ ? = call info_user_select_statements_spd (?) }</sql-delete>
       <sql-update callable="true">{ ? = call info_user_select_statements_spu (?,?,?,?,?,?,?) }</sql-update>
      
    </class>

    <sql-query name="info_user_selects_list_spr" callable="true">
       <return alias="hbmUserSelectStatements" class="HbmUserSelectStatements"/>
       <![CDATA[
       { call info_user_selects_list_spr(?) }
       ]]>
    </sql-query>
   
    <sql-query name="info_user_select_statements_spr" callable="true">
       <return alias="hbmUserSelectStatements" class="HbmUserSelectStatements"/>
       <![CDATA[
       { call info_user_select_statements_spr(?) }
       ]]>
    </sql-query>
   
</hibernate-mapping>


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.