-->
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: ClassCastException with EntityMode.DOM4J in 3.1
PostPosted: Tue Aug 16, 2005 7:12 pm 
Newbie

Joined: Thu Sep 23, 2004 2:33 pm
Posts: 1
I'm trying to export/import to/from XML and MS SQL Server using the new EntityMode.DOM4J. It works great for most of the tables and even creates the appropriate XML for one of our link (a.ka. join) tables. I ahve a requirement to just import/export the join table and that fails with a ClassCastException. I have already searched the forums and have seen HHH-393. It looked similar and is fixed in 3.0.5 so I should have the fix (if that's the same problem).

Thanks.

Eric.


Hibernate version: 3.1beta2

Mapping documents:
<?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="com.marketlive.entity.helper">
<class name="com.marketlive.entity.helper.ProductSkuLink" table="PRODUCT_SKU_LINK" lazy="false">

<composite-id name="pk" class="com.marketlive.entity.helper.ProductSkuLinkPk">
<key-property name="productPk" column="PRODUCT_ID" type="com.marketlive.entity.IntegerPkType"/>
<key-property name="skuPk" column="SKU_ID" type="com.marketlive.entity.IntegerPkType"/>
</composite-id>

<version name="version" column="VERSION" type="integer" unsaved-value="negative"/>

<property name="defaultProd" type="boolean" column="IS_DEFAULT"/>
<property name="dateCreated" type="timestamp" column="DATE_CREATED" update="false"/>

<!-- bi-directional many-to-one association to Category -->
<many-to-one name="sku" column="SKU_ID" insert="false" update="false" not-null="true"
class="com.marketlive.entity.sku.Sku"
foreign-key="PRODUCT_SKU_LINK_FK02"/>

<!-- bi-directional many-to-one association to Product -->
<many-to-one name="product" column="PRODUCT_ID" insert="false" update="false" not-null="true"
class="com.marketlive.entity.product.Product"
foreign-key="PRODUCT_SKU_LINK_FK01"
embed-xml="false"
/>

</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

SAXReader reader = new SAXReader();
Document doc = reader.read(new File("c:\\productSkuLinks.xml"));

Session session = HibernateUtil.currentSession();
Session s = session.getSession(EntityMode.DOM4J);
Transaction txn = session.beginTransaction();
{
List elems = doc.getRootElement().elements();
System.out.println("Number of elems: " + elems.size());
Iterator it = elems.iterator();
while(it.hasNext())
{
Element e = (Element)it.next();
s.replicate("com.marketlive.entity.helper.ProductSkuLink", e, ReplicationMode.OVERWRITE);
}
}

txn.commit();

HibernateUtil.closeSession();


Full stack trace of any exception that occurs:

java.lang.ClassCastException: com.marketlive.entity.helper.ProductSkuLinkPk
at org.hibernate.property.Dom4jAccessor$ElementGetter.get(Dom4jAccessor.java:191)
at org.hibernate.tuple.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:61)
at org.hibernate.tuple.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:67)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:257)
at org.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:230)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:188)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1456)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1518)
at org.hibernate.loader.Loader.doQuery(Loader.java:638)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:221)
at org.hibernate.loader.Loader.doList(Loader.java:1959)
at org.hibernate.loader.Loader.list(Loader.java:1943)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1314)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:298)
at com.marketlive.entity.product.ProductTest.testExportProductSkuLinks(ProductTest.java:163)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 11:32 am 
Newbie

Joined: Thu Jun 22, 2006 11:29 am
Posts: 1
Hi,
I am having the same problem. Does anyone know if this is fixed yet?

Thanks.


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.