-->
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: Help in XML import with many-to-one relationship
PostPosted: Fri Dec 02, 2005 2:39 am 
Newbie

Joined: Tue Nov 29, 2005 2:43 am
Posts: 9
I am trying to import an object that has got <many-to-one> mapping from an XML. Following is my xml:

    <CategoryName metadataid="1">
    <version>16</version>
    <name>Infrastructure</name>
    <description>Infrastructure</description>
    <displayorder>4</displayorder>
    <WFP wfpId="1"/>
    <skills></skills>
    <CategoryName>

The maping file of the above object as follows:

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping package="wfp.domain">
    <class name="CategoryName"
    entity-name="wfp.domain.CategoryName"
    table="category_name"
    dynamic-update="true"
    node="CategoryName">

    <id name="metadataId" column="category_name_id" node="@metadataid">
    <generator class="native"/>
    </id>

    <version name="version" unsaved-value="null" node="version"/>

    <property name="name" type="string" not-null="true" unique="true" node="name"/>
    <property name="description" type="string" not-null="true" node="description"/>
    <property name="displayOrder" column="display_order" not-null="true" node="displayorder"/>

    <many-to-one name="wfp" column="wfp_id" not-null="true" node="WFP/@wfpId" embed-xml="false"/>

    <list name="skills" cascade="all" inverse="true" lazy="false">
    <key column="category_name_id"/>
    <list-index column="display_order" base="0"/>
    <one-to-many class="SkillName"/>
    </list>
    </class>
    </hibernate-mapping>


Now, when I import it using the session.replicate() method it falls over in Dom4jAccessor class in Hibenate at following method:

Code:
      public Object get(Object owner) throws HibernateException {
         Element ownerElement = (Element) owner;
         Node attribute = ownerElement.attribute(attributeName);
         return attribute==null ? null :
            super.propertyType.fromXMLNode(attribute, super.factory);
      }


It generates a ClassCastException at "Element ownerElement = (Element) owner" line. I debuged it and found out that it passes the "Long" object when process the many-to-one relationship of CategoryName, to this method instead of a "DefaultElement" object.
Is there anyway way to avoid this problem? Help!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 7:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
add it to JIRA with a small test case


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.