标签:style blog http ar io color os sp for
Hibernate Annotations
Mapping composite primary keys and foreign keys to composite primary keys:
http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#d0e2177
引用Composite primary keys use a embedded class as the primary key representation, so you‘d use the @Id and @Embeddable annotations. Alternatively, you can use the @EmbeddedId annotation. Note that the dependent class has to be serializable and implements equals()/hashCode(). You can also use @IdClass.
@Entity public class RegionalArticle implements Serializable { @Id public RegionalArticlePk getPk() { ... } } @Embeddable public class RegionalArticlePk implements Serializable { ... }or alternatively
@Entity public class RegionalArticle implements Serializable { @EmbeddedId public RegionalArticlePk getPk() { ... } } public class RegionalArticlePk implements Serializable { ... }
Hibernate @IdClass @EmbeddedID相关注解
标签:style blog http ar io color os sp for
原文地址:http://blog.csdn.net/love_xsq/article/details/41981511