I'm trying to set up a class with a lot of sets of dependant classes. An abstract base class defines stuff like the primary ID and other needed functionality, while all the other classes just extend this base class.
So there is
* one abstract base class
AC
* one class
C which extends AC and holds a number of java.util.Set properties, filled with one of C1, C2, C3
* a number of classes
C1, C2, C3 which also extend AC and will only complement C
The relevant Java code looks like this:
Code:
private Set texte = Collections.EMPTY_SET;
/**
* @return Returns the text.
* @hibernate.set lazy="true"
* sort="com.pi.tcomadm.entities.components.Version"
* @hibernate.collection-key column="tarif_id"
* @hibernate.collection-one-to-many class="com.pi.tcomadm.entities.TarifText"
*/
public Set getTexte() {
return this.texte;
}
XDoclet happily transforms this into a mapping document for class C that contains Set definitions like this one:
Code:
<set
name="texte"
lazy="true"
inverse="false"
cascade="none"
sort="com.pi.tcomadm.entities.components.Version"
>
<key
column="tarif_id"
/>
<one-to-many
class="com.pi.tcomadm.entities.TarifText"
/>
</set>
Class
com.pi.tcomadm.entities.TarifText is one of the classes C1, C2, C3 which extend AC. When I try to start my application, it throws the exception found below. My questions are:
* Is this the preferred "hibernated" way of designing the data?
* What do I have to do in order to avoid that exception?
* Why does Hibernate throw an exception about class [em]TarifartKombination[/em] which isn't even accessed in the given example, and which worked before I started implementing the classes AC, C, C1, C2, C3...?
Any help is greatly appreciated. Best regards,
- Christian
Hibernate version: 2.1.7 built from CVS
Name and version of the database you are using: mySQL 4.0.18 w/ mySQL JDBC Driver 3.0 (production)
Full stack trace of any exception that occurs:Code:
net.sf.hibernate.MappingException: Repeated column in mapping for class com.pi.tcomadm.entities.TarifartKombination should be mapped with insert="false" update="false": id
at net.sf.hibernate.persister.AbstractEntityPersister.checkColumnDuplication(AbstractEntityPersister.java:1015)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:819)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:792)
at com.pi.portal.tools.Setup.run(Setup.java:43)
at com.pi.portal.tools.Setup.main(Setup.java:32)