-->
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.  [ 7 posts ] 
Author Message
 Post subject: polymorphic collection with table-per-concrete-class
PostPosted: Sat Jan 15, 2005 2:02 pm 
Newbie

Joined: Wed Nov 24, 2004 2:44 pm
Posts: 13
hello *,

how can I map a polymorphic collection with table-per-concrete-class?
E.g. I have a class Person (with a table person) with a set of pets and the classes cat and dog. The classes cat and dog extend the abstract class pet. Each person has cat's and/or dogs and each pet has exactly one person as owner.

Which example in the doc fits to this question? Do I have to use a "set" or "any"?

Thank you!

Regards Richard


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2005 2:20 pm 
Newbie

Joined: Tue Dec 21, 2004 5:30 pm
Posts: 7
http://www.hibernate.org/hib_docs/refer ... strategies


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2005 2:56 pm 
Newbie

Joined: Wed Nov 24, 2004 2:44 pm
Posts: 13
Sorry, but I can't find any informations about collections on this page?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2005 7:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You can use <many-to-any> in Hibernate2, or, much better, a <union-subclass> mapping in Hibernate3.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 19, 2005 2:38 pm 
Newbie

Joined: Wed Nov 24, 2004 2:44 pm
Posts: 13
I have a problem with the <many-to-any> mapping and can’t find any example in the reference doc or the “hibernate in action” book. Have I overlook it? Can I find something on the web?

Thanks Richard


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 19, 2005 2:46 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
chapter 6.10 reference docs


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 7:51 am 
Newbie

Joined: Wed Nov 24, 2004 2:44 pm
Posts: 13
I changed the mapping file from any to many-to-any and get this error during the schema-creation:

INFO: Mapping file: hbm/ena/ui/molecule/MoleculeText.hbm.xml
Jan 19, 2005 9:38:22 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: ena.ui.molecule.MoleculeText -> MoleculeText
Jan 19, 2005 9:38:22 PM net.sf.hibernate.cfg.Configuration addFile
INFO: Mapping file: hbm/ena/ui/panel/MoleculePanel.hbm.xml
Jan 19, 2005 9:38:22 PM net.sf.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: hbm/ena/ui/panel/MoleculePanel.hbm.xml(17) Attribute "name" must be declared for element type "many-to-any".
Jan 19, 2005 9:38:22 PM net.sf.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: hbm/ena/ui/panel/MoleculePanel.hbm.xml(17) Attribute "cascade" must be declared for element type "many-to-any".
Jan 19, 2005 9:38:22 PM net.sf.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: hbm/ena/ui/panel/MoleculePanel.hbm.xml(17) The content of element type "many-to-any" is incomplete, it must match "(meta-value*,column,column+)".
Jan 19, 2005 9:38:22 PM net.sf.hibernate.util.XMLHelper$ErrorLogger error

My mapping file is:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
package="ena.ui.panel">

<class name="MoleculePanel" table="MoleculePanel" >
<id name="Id">
<generator class="native"/>
</id>
<property name="PanelTitle"/>

<many-to-any name="moleculeVector"
meta-type="string"
id-type="long"
cascade="save-update">
<meta-value value="MoleculeText" class="ena.ui.molecule.MoleculeText"/>
<meta-value value="MoleculeDate" class="ena.ui.molecule.MoleculeDate"/>
<column name="molecule_TYPE"/>
<column name="molecule_ID"/>
</many-to-any>


</class>

</hibernate-mapping>

Thank you!

Richard


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