How to create a hashmap with 2 foreign keys as reference? Something like, Table 3 have a hashmap that for each table1 id have an id from table2.
@Entity
public class table1 implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
...
@Entity
public class table2 implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
...
I was trying something like this:
@Entity
public class table3 implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;
@ElementCollection
@MapKeyJoinColumn(name = "table1", referencedColumnName = "ID")
@MapKeyJoinColumn(name = "table2", referencedColumnName = "ID")
private Map<table1, table2> hashmap_relation = new LinkedHashMap<table1, table2>();
...