-->
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: Custom persister and many-to-one relationship
PostPosted: Wed Dec 28, 2005 8:24 pm 
Newbie

Joined: Mon May 03, 2004 2:28 am
Posts: 12
I am experimenting with custom persisters, specifically with relationships betwen db-persisted entities and custom-persisted entities. Unfortunately when I try to create a many-to-one relationship from a db-persisted entity to a custom-persisted entity I get a ClassCastException. The code in org.hibernate.persister.collection.AbstractCollectionPersister.getElementPersister(AbstractCollectionPersister.java:1179)
is casting the persister to a Loadable.

I am using MasterDetail.hbm.xml and Custom.hbm.xml. I have added a set of Custom objects to the Master class definition. When I try to run MasterDetailTest as a java application I get the exception (shown below).

Can anyone give me any pointers as to whether it is possible to get relationships working between entities persisted with different persisters?

I have tried this with NHibernate 1.0.1, hibernate 2.1.6 and 3.0 with similar results.

Thanks in anticipation!

Hibernate version:
2.1 & 3.0 & NHibernate 1.0.1

Mapping documents:
I used MasterDetail.hbm.xml & Custom.hbm.xml. Amended MasterDetail.hbm.xml to add:
Code:
   <set name="customs" lazy="true">
      <key/>
      <one-to-many class="org.hibernate.test.legacy.Custom"/>
   </set>

to mapping for org.hibernate.test.legacy.Master class. I have added appropriate code to Master.java:
Code:
   private Collection customs;
   public Collection getCustoms() {
      return customs;
   }
   public void setCustoms(Collection customs) {
      this.customs = customs;
   }

Code between sessionFactory.openSession() and session.close():
N/A. I am running org.hibernate.test.legacy.MasterDetailTest as a java application

Full stack trace of any exception that occurs:
java.lang.ClassCastException: org.hibernate.test.legacy.CustomPersister
at org.hibernate.persister.collection.AbstractCollectionPersister.getElementPersister(AbstractCollectionPersister.java:1179)
at org.hibernate.loader.collection.OneToManyLoader.<init>(OneToManyLoader.java:84)
at org.hibernate.loader.collection.OneToManyLoader.<init>(OneToManyLoader.java:69)
at org.hibernate.loader.collection.OneToManyLoader.<init>(OneToManyLoader.java:60)
at org.hibernate.loader.collection.BatchingCollectionInitializer.createBatchingOneToManyInitializer(BatchingCollectionInitializer.java:72)

Name and version of the database you are using:
hsql 1.7.1

The generated SQL (show_sql=true):
N/A

Debug level Hibernate log excerpt:
N/A
Code:


Top
 Profile  
 
 Post subject: any more information?
PostPosted: Mon Feb 20, 2006 11:28 pm 
Newbie

Joined: Mon May 03, 2004 2:28 am
Posts: 12
Can anyone give me any pointers as to whether it is possible to have relationships between entities persisted with different (i.e. non-DB) persisters?


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.