抛出异常,表示实体

时间:2017-05-09 10:45:35

标签: hibernate jpa

 @Entity
    @Table(name = "COUNTRY")
    @Embeddable
    public class Country implements Serializable {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        @Column(name = "CTRY_ID_NBR", nullable = false)
        private Integer countryIdNumber;

        @Column(name = "CTRY_CD_NM", nullable = false)
    private String countryCodeName;

    @Column(name = "CTRY_NM")
    private String countryName;

    @Column(name = "CTRY_CUR_SUFFIX_NM")
    private String countryCurrencySuffixName;

    @Column(name = "CTRY_CUR_CD_NM")
    private String countryCurrencyCodeName; 
} 
@Entity
@Table(name = "LANG")
@Embeddable
    public class Lang implements Serializable {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        @Column(name = "LANG_ID_NBR")
        private Integer langIdNumber;

        @Column(name = "CTRY_ID_NBR", insertable = false, updatable = false)
        private Integer countryIdNumber;

        @Column(name = "LANG_CD_NM")
        private String langCodeName;

        @Column(name = "LANG_NM")
        private String langName;}
  @Entity
    public class LangDto {

        @Embedded
        @AttributeOverrides({ @AttributeOverride(name = "countryIdNumber", column = @Column(name = "CTRY_ID_NBR")),
                @AttributeOverride(name = "langCodeName", column = @Column(name = "LANG_CD_NM")),
                @AttributeOverride(name = "langName", column = @Column(name = "LANG_NM")) })
        private Lang lang;

        @ManyToOne
        @JoinColumn(name = "CTRY_ID_NBR", nullable = false)
        private CountryDto countryDto;
    }
 @Entity
    public class CountryDto {

        @Embedded
        @AttributeOverrides({ @AttributeOverride(name = "countryIdNumber", column = @Column(name = "CTRY_ID_NBR")),
                @AttributeOverride(name = "countryCodeName", column = @Column(name = "CTRY_CD_NM")),
                @AttributeOverride(name = "countryName", column = @Column(name = "CTRY_NM")),
                @AttributeOverride(name = "countryCurrencySuffixName", column = @Column(name = "CTRY_CUR_SUFFIX_NM")),
                @AttributeOverride(name = "countryCurrencyCodeName", column = @Column(name = "CTRY_CUR_CD_NM")) })
        private Country country;



        @OneToMany(mappedBy = "countryDto", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
        private List<LangDto> lang;

这里Country和Lang是可嵌入的实体类。当我尝试编译项目时。编译器抛出此异常

org.hibernate.AnnotationException: No identifier specified for entity: com.fedex.ftt.nexgen.dto.LangDto

是否应遵循此设计模式?我正在从映射这些表的dto包中的域(这是一个由所有实体类组成的不同项目)中提取Country和Lang。 谢谢

0 个答案:

没有答案