Je suis en train de cartographier une relation de ManyToMany entre 2 tables, les deux ayant des clés primaires compositesmapping Hibernate @ManyToMany avec les touches composites
LSFOCTB which primary key is composed of : LSFOC_CODSOC,LSFOC_CODLSC,LSFOC_CODFOC
LSFORTB which primary key is composed of : LSFOR_CODSOC,LSFOR_CODLSC,LSFOC_CODFOR
The table in charge of the ManyToMany relationship is :
LSFCFTB, with : LSFCF_CODSOC,LSFCF_CODLSC,LSFCF_CODFOC,LSFCF_CODFOR
Ainsi, dans le LSFOCTB de cartographie modèle de mise en veille prolongée, j'ai essayé:
@ManyToMany(targetEntity = package.LSFOCTB.class, cascade = { CascadeType.PERSIST,
CascadeType.MERGE })
@JoinTable(name = "LSFCFTB", joinColumns = {
@JoinColumn(name = "LSFCF_CODLSC", referencedColumnName = "LSFOC_CODLSC"),
@JoinColumn(name = "LSFCF_CODFOC", referencedColumnName = "LSFOC_CODFOC"),
@JoinColumn(name = "LSFCF_CODSOC", referencedColumnName = "LSFOC_CODSOC") },
inverseJoinColumns = { @JoinColumn(name = "LSFCF_CODLSC", referencedColumnName = "LSFOR_CODLSC"),
@JoinColumn(name = "LSFCF_CODFOR", referencedColumnName = "LSFOR_CODFOR"),
@JoinColumn(name = "LSFCF_CODSOC", referencedColumnName = "LSFOR_CODSOC") })
avant le getter. Mais ça ne marchera pas ... L'erreur, lorsque vous essayez d'accéder à la collection est lointaine:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [beans-dao.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for collection: package.LSFOCTB.distantCollection column: LSFCF_CODLSC
Ont déjà réussi à faire un travail de cartographie de mise en veille prolongée pour une relation ManyToMany? Si oui, quel est le problème avec ma cartographie? Nous vous remercions de votre aide!
J'ai cherché des informations sur les pages suivantes: http://www.hibernate.org/hib_docs/annotations/reference/fr/html/entity.html#entity-hibspec chapitre: 2.2.5.3.3. Beaucoup à plusieurs et aussi: http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=78&t=003838 –