-->
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.  [ 1 post ] 
Author Message
 Post subject: Using a java.util.Map
PostPosted: Wed Jun 13, 2007 10:43 am 
Newbie

Joined: Thu May 10, 2007 11:31 pm
Posts: 2
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.