-->
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.  [ 2 posts ] 
Author Message
 Post subject: problem with subclass mapping
PostPosted: Sat Apr 05, 2008 11:02 am 
Newbie

Joined: Fri Apr 04, 2008 4:13 am
Posts: 5
Sorry to post it again, but it's really a emergency problem need to solve.
I map it with joined-subclass first and everything is ok. But when i try to map it with subclass tag i got the Exception.
Tks for any help.

3.1

<?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>
<class name="cn.test.dao.model.Metadata" table="metadata" catalog="test">
<id name="metaId" type="java.lang.String">
<column name="meta_id" length="48" />
<generator class="uuid" />
</id>
<discriminator column="meta_type" type="string"/>
<many-to-one name="member" class="cn.test.dao.model.Member" fetch="select" >
<column name="member_id" length="48" not-null="true" />
</many-to-one>
<many-to-one name="sort" class="cn.test.dao.model.Sort" fetch="select" lazy="false">
<column name="sort_id" length="48" not-null="true" />
</many-to-one>
<many-to-one name="city" class="cn.test.dao.model.City" fetch="select" lazy="false">
<column name="city_id" length="48" />
</many-to-one>
<property name="title" type="java.lang.String">
<column name="title" />
</property>
<property name="content" type="java.lang.String">
<column name="content" not-null="true" />
</property>
<property name="createtime" type="java.util.Date">
<column name="createtime" length="23" />
</property>
<property name="updatetime" type="java.util.Date">
<column name="updatetime" length="23" />
</property>
<property name="viewcounts" type="java.lang.Integer">
<column name="viewcounts" />
</property>
<property name="keywords" type="java.lang.String">
<column name="keywords" />
</property>
<property name="status" type="java.lang.Short">
<column name="status" />
</property>
<property name="price" type="java.math.BigDecimal">
<column name="price" />
</property>
<set name="videos" inverse="true" table="metadata_videos" catalog="test">
<key>
<column name="meta_id" length="48" not-null="true" />
</key>
<many-to-many entity-name="cn.test.dao.model.Video">
<column name="video_id" length="48" not-null="true" />
</many-to-many>
</set>
<set name="tags" inverse="true">
<key>
<column name="meta_id" length="48" />
</key>
<one-to-many class="cn.test.dao.model.Tag" />
</set>
<set name="attributeSets" inverse="true">
<key>
<column name="meta_id" length="48" not-null="true" />
</key>
<one-to-many class="cn.test.dao.model.AttributeSet" />
</set>
<set name="comments" inverse="true">
<key>
<column name="meta_id" length="48"/>
</key>
<one-to-many class="cn.test.dao.model.Comment" />
</set>
<set name="metadataHistories" inverse="true">
<key>
<column name="meta_id" length="48" not-null="true" />
</key>
<one-to-many class="cn.test.dao.model.MetadataHistory" />
</set>
<set name="photos" table="metadata_photos" inverse="true" cascade="all" catalog="test">
<key>
<column name="meta_id" length="48" not-null="true" />
</key>
<many-to-many entity-name="cn.test.dao.model.Photo">
<column name="photo_id" length="48" not-null="true" />
</many-to-many>
</set>
<set name="itineraries" table="itinerary_metadata" catalog="test" inverse="true">
<key>
<column name="meta_id" length="48" not-null="true" />
</key>
<many-to-many entity-name="cn.test.dao.model.Itinerary">
<column name="itinerary_id" length="48" not-null="true" />
</many-to-many>
</set>
<subclass name="cn.test.dao.model.Hotel" discriminator-value="hotel">
<join table="hotel">
<key column="meta_id"/>
<property name="ranking" type="java.lang.Integer">
<column name="ranking" />
</property>
<property name="address" type="java.lang.String">
<column name="address" />
</property>
<property name="phone" type="java.lang.String">
<column name="phone" />
</property>
<property name="zip" type="java.lang.String">
<column name="zip" />
</property>
<property name="location" type="java.lang.String">
<column name="location" />
</property>
<property name="rate" type="java.lang.String">
<column name="rate" />
</property>

<property name="facility" type="java.lang.String">
<column name="facility" />
</property>

<property name="roomAmenity" type="java.lang.String">
<column name="room_amenity" />
</property>
<property name="extraBedPrice" type="java.math.BigDecimal">
<column name="extra_bed_price" />
</property>
<property name="breakfastPrice" type="java.math.BigDecimal">
<column name="breakfast_price" />
</property>

<property name="rankings" type="java.math.BigDecimal">
<column name="rankings" />
</property>
<set name="rooms" inverse="true" cascade="all">
<key>
<column name="hotel_id" length="48"/>
</key>
<one-to-many class="cn.test.dao.model.Room" />
</set>
</join>
</subclass>
<subclass name="cn.test.dao.model.Room" discriminator-value="room">
<join table="room">
<key column="meta_id"/>
<property name="bed" type="java.lang.Integer">
<column name="bed" />
</property>
<many-to-one name="hotel" class="cn.test.dao.model.Hotel">
<column name="hotel_id" length="48" />
</many-to-one>
</join>
</subclass>
</class>
</hibernate-mapping>



Caused by: org.xml.sax.SAXParseException: The content of element type "join" must match "(subselect?,comment?,key,(property|many
to-one|component|dynamic-component|any)*,sql-insert?,sql-update?,sql-delete?)".
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.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:505)
... 74 more

mysql5.5


Top
 Profile  
 
 Post subject: Re: problem with subclass mapping
PostPosted: Mon Apr 07, 2008 2:05 am 
Newbie

Joined: Fri Apr 04, 2008 4:13 am
Posts: 5
Solved, Ha Ha
After a short study of hibernate dtd, i got the answer. Just move the set tag out of join.

Code:
<subclass name="cn.text.dao.model.Hotel" discriminator-value="hotel"  >
        <set name="rooms" inverse="true" cascade="all">
            <key>
                <column name="hotel_id" length="48"/>
            </key>
         <one-to-many class="cn.text.dao.model.Room" />
        </set>
        <join table="hotel" fetch="select">
        <key column="meta_id"/>
        <property name="ranking" type="java.lang.Integer">
            <column name="ranking" />
        </property>
        <property name="address" type="java.lang.String">
            <column name="address" />
        </property>
        <property name="phone" type="java.lang.String">
            <column name="phone" />
        </property>
        <property name="zip" type="java.lang.String">
            <column name="zip" />
        </property>
        <property name="location" type="java.lang.String">
            <column name="location" />
        </property>
        <property name="rate" type="java.lang.String">
            <column name="rate" />
        </property>
       
        <property name="facility" type="java.lang.String">
            <column name="facility" />
        </property>
       
        <property name="roomAmenity" type="java.lang.String">
            <column name="room_amenity" />
        </property>
        <property name="extraBedPrice" type="java.math.BigDecimal">
            <column name="extra_bed_price" />
        </property>
        <property name="breakfastPrice" type="java.math.BigDecimal">
            <column name="breakfast_price" />
        </property>
       
        <property name="rankings" type="java.math.BigDecimal">
            <column name="rankings" />
        </property>
   </join>
   </subclass>


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