我的实体之间可能有一个方向关系。 (实体是虚拟名称)
@Entity
public class Entity {
...
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer Entity_id;
...
@ManyToMany()
@JoinTable(name = "Entity2Entity", joinColumns =
@JoinColumn(name = "EntityLeft_id", referencedColumnName="Entity_id"), inverseJoinColumns =
@JoinColumn(name = "EntityRight_id", referencedColumnName="Entity_id"))
private Set<Entity> Left2Right = new HashSet<Entity>();
@ManyToMany(mappedBy = "Left2Right")
private Set<Entity> Right2Left = new HashSet<Entity>();
但我想用加时间戳数据列扩展这种关系。
使用EclipseLink 2.5 api可以做到这一点吗?
如果没有,我读到我可以用OneToMany连接做到这一点,但我不知道如何。
我也为Entity2Entity创建了一个Entity:
@Entity
public class Entity2Entity {
...
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer Entity2Entity_id;
private Entity EntityLeft_id;
private Entity EntityRight_id;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created", nullable = false, columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable=false, updatable=false)
private java.util.Date created;
但我无法连接它们。