Created
January 14, 2013 05:58
-
-
Save gaol/4528002 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
@Table(name = "Affected_Product") | |
public class AffectedProduct implements Serializable{ | |
@Id | |
@GeneratedValue | |
private Long id; | |
@OneToMany(fetch = FetchType.LAZY, mappedBy = "product", cascade = {CascadeType.ALL}) | |
@JoinTable | |
private Collection<LinkData> fixLocations; | |
@OneToMany(fetch = FetchType.LAZY, mappedBy = "product", cascade = {CascadeType.ALL}) | |
private Collection<LinkData> brewLinks; | |
} | |
@Entity | |
@Table(name = "link_data") | |
public class LinkData implements Serializable{ | |
@Id | |
@GeneratedValue | |
private Long id; | |
@Column | |
private String type; | |
@ManyToOne | |
@JoinColumn(name = "affected_product_id", referencedColumnName = "id") | |
private AffectedProduct product; | |
} | |
// 这里除了 affected_product_id 这个字段外,还想使用 type 的值。 | |
// 比如: type=brew 的时候, 对应的是 brewLinks 列表 | |
// type= fixlocation 的时候, 对应的是 fixLocation 列表 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment