You can model the association as a separate entity Association. Temporary data can be modeled as regular attributes Date(like @Temporal(TemporalType.TIMESTAMP)).
You can model PK associations as part of foreign keys Entity_1and Entity_2- this will make the association a dependent object. Or you can assign it your own identifier and connect to Entity_1and Entity_2through the ManyToOne relationship.
. @Vlad, , , .
@Column(updatable=false) Date, , @Temporal(TemporalType.TIMESTAMP), JPA , , .
, mappedBy () JoinColumn ().
@Entity
public class Association {
@Id
@GeneratedValue(...)
private Long id;
@Column
@Temporal(TemporalType.TIMESTAMP)
private Date affectation;
@Column
@Temporal(TemporalType.TIMESTAMP)
private Date expiration;
@ManyToOne(fetch=FetchType.LAZY)
private Entity1 entity1;
@ManyToOne(fetch=FetchType.LAZY)
private Entity2 entity2;
}
Entity1 Entity2 , . Set, List, , , - .
public class Entity1 {
@OneToMany(mappedBy="entity1")
private List<Association> associations = new ArrayList<Association>();
...
}