Hi. I have problems. My mapping is not working.
PastaDeDocumentos has a Map<String, PlanoMensal>. The key is a String tipo of PlanoMensal.
Classes:
public class PastaDeDocumentos {
private Map<String, PlanoMensal> planos = new Hashtable<String, PlanoMensal>();
......
}
public abstract class PlanoMensal {
private PastaDeDocumentos pasta;
....
}
Mapping:
PastaDeDocumentos.hbm.xml
<hibernate-mapping>
<class name="org.sisenf.gerencial.model.PastaDeDocumentos">
<id name="id">
<generator class="increment"/>
</id>
<map name="planos" cascade="all" lazy="false" inverse="true">
<key column="id" not-null="true"/>
<map-key column="tipo" type="string"/>
<one-to-many class="org.sisenf.gerencial.model.PlanoMensal"/>
</map>
</class>
</hibernate-mapping>
PlanoMensal.hbm.xml
<hibernate-mapping>
<class name="org.sisenf.gerencial.model.PlanoMensal">
<id name="id">
<generator class="increment"/>
</id>
<many-to-one
name="pasta"
class="org.sisenf.gerencial.model.PastaDeDocumentos"
column="id"
not-null="true"
update="false"
insert="false"
/>
<property name="tipo" />
</class>
</hibernate-mapping>
Schema:
CREATE TABLE PastaDeDocumentos (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
);
CREATE TABLE PlanoMensal (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
PastaDeDocumentos_id INTEGER UNSIGNED NOT NULL,
tipo VARCHAR(10) NULL,
PRIMARY KEY(id),
INDEX PlanoMensal_FKIndex1(PastaDeDocumentos_id),
FOREIGN KEY(PastaDeDocumentos_id)
REFERENCES PastaDeDocumentos(id)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
The following error appears:
1:28:49,578 INFO DefaultLoadEventListener:111 - Error performing load command
org.hibernate.HibernateException: null index column for collection: org.sisenf.gerencial.model.PastaDeDocumentos.planos
at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:710)
|