Hibernate version: 3.2.5.ga
Hibernate annotations 3.3.0.ga
I had a problem with a Map relationship between three entites,
they were mapping this way:
Code:
/**
* @return Regresa el valor de listasPorZona.
*/
@CollectionOfElements
@MapKeyManyToMany
@LazyCollection(value = LazyCollectionOption.FALSE)
@Cascade(org.hibernate.annotations.CascadeType.ALL)
public Map<CentroEmbarcador, ListaPrecios> getlistasCentroEmbarcador() {
return listasCentroEmbarcador;
}
As shown in the hibernate annotation reference part
2.4.6.2.2. Map. But I added the @LazyCollection and @Cascade annotations since I wanted to cascade the save operation on the owner of this map to the values of the map.
The problem was that the @Cascade didn't work cause save threw the
org.hibernate.TransientObjectException.
But I found in this thread
http://forum.hibernate.org/viewtopic.php?t=974839 (apparently unrelated, since that guy seems to have a different prob lem) that Emmanuel recommended to change the @CollectionOfElements for @ManyToMany. I did the change and voila! @Cascade worked.
My question is why? Whats the semantics of @CollectionOfElements with @MapKeyManyToMany?
regards,
Miguel