2013-06-04 3 views
0

Je suis aux prises avec le scénario suivant:un à plusieurs cartographie unidirectionnel avec le composé

J'ai 2 tableaux:

RESULTS (
`L_ID` int(10) unsigned NOT NULL, 
`PRIZE` int(10) unsigned NOT NULL, 
`SECONDARY_PRIZE` int(10) unsigned NOT NULL, 
PRIMARY KEY (`L_ID`) 
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | 


STATISTICS (
`L_ID` int(10) unsigned NOT NULL, 
`F_TYPE` int(10) unsigned NOT NULL, 
`RANK` varchar(2) NOT NULL, 
`WINNERS` int(10) unsigned NOT NULL, 
`PRIZE` int(10) unsigned NOT NULL, 
PRIMARY KEY (`L_ID`,`F_TYPE`,`RANK`), 
KEY `L_ID_FK_idx` (`L_ID`), 
CONSTRAINT `L_ID` FOREIGN KEY (`L_ID`) REFERENCES `RESULTS` (`L_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION 
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | 

Et les classes suivantes:

@Embeddable 
public class StatisticId implements Serializable { 

    @Column(name = "L_ID", unique=false, nullable=false, updatable=true, insertable=true) 
    private long lId; 

    @Column(name = "F_TYPE", unique=false, nullable=false, updatable=true, insertable=true) 
    private int fType; 

    @Column(name = "RANK_ID", unique = false, nullable = false, updatable = true, insertable = true, length = 2) 
    private String rankId; 

    ..Getters\Setters... 
} 

La statistique Classe:

@Entity 
@Table(name = "STATISTICS", uniqueConstraints = {}) 
public class Statistic implements Serializable { 

    @EmbeddedId 
    @AttributeOverrides({ 
    @AttributeOverride(name = "lId", column = @Column(name = "L_ID", unique = false, nullable = false, insertable = true, updatable = true)), 
    @AttributeOverride(name = "fType", column = @Column(name = "F_TYPE", unique = false, nullable = false, insertable = true, updatable = true)), 
    @AttributeOverride(name = "rankId", column = @Column(name = "RANK_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 2)) 
    }) 
    private StatisticId id; 


    @Column(name = "WINNERS", unique = false, nullable = false, updatable = true, insertable = true) 
    private long winners; 

    @Column(name = "PRIZE", unique = false, nullable = false, updatable = true, insertable = true) 
    private long prize; 
} 

et enfin le tableau des résultats:

J'utilise Hibernate4.3beta avec sa Proxool connexion de la piscine.

L'exception que je reçois est:

org.hibernate.AnnotationException: A Foreign key refering  
com.btl.server.database.beans.Statistic from com.btl.server.database.beans.Result has the wrong 
number of column. should be 2 

Qu'est-ce que je fais essorer ??

Merci pour votre patience en lisant ceci !!

Répondre

0

Résolu !! Le problème était HIbernate4.3 version bêta, une fois que je suis passé à 4.2.1Final cela a fonctionné comme une magie !!

Questions connexes