JPA エンティティに列挙型の 1 つのフィールドを使用します。
@Enumerated(value=EnumType.STRING)
private Temperament temperament = Temperament.MINEUR_PUR;
私の列挙型は私のエンティティ内で宣言されています:
@Entity
public class Joueur implements Serializable {
.....
public enum Temperament{
MINEUR_PUR(30),
MINEUR(10),
NEUTRE(0),
RAIDEUR(-10),
RAIDEUR_PUR(-30);
private int temperament_prod_mines;
private Temperament(int temperament_prod_mines){
this.temperament_prod_mines = temperament_prod_mines;
}
public int getTemperament_prod_mines() {
return temperament_prod_mines;
}
public void setTemperament_prod_mines(int temperament_prod_mines) {
this.temperament_prod_mines = temperament_prod_mines;
}
}
}
それは機能しますが、独自のファイルで列挙型を「外部化」すると、機能しなくなります:
原因: 例外 [EclipseLink-7151] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException Exception 説明: タイプ [class com.sim.basics.enums.Temperament] forエンティティ クラス [class com.sim.entities.Joueur] の属性 [気質] は、列挙されたマッピングの有効なタイプではありません。属性は、Java 列挙型として定義する必要があります。
しかし、それは単なるコピー&ペーストです...
なぜこの動作ですか?
ありがとう