连接带有额外列和@ElementCollection的表

时间:2017-10-18 19:03:03

标签: java database hibernate jpa

我需要create和elementcollection属性,但我需要在集合中添加额外的列,如替代名称。

上面在mkyong网站上描述了所有实体。

@Entity
@Table(name = "stock", catalog = "mkyongdb", uniqueConstraints = { 
    @UniqueConstraint(columnNames = "STOCK_NAME"),
    @UniqueConstraint(columnNames = "STOCK_CODE") })
public class Stock implements java.io.Serializable {

private Integer stockId;
private String stockCode;
private String stockName;

@ElementCollection
@OneToMany(fetch = FetchType.LAZY)
@MapKeyColumn(name = "indice")
private Map<Integer,StockCategory> stockCategories = new HashMap<Integer,StockCategory>();
...
}

https://www.mkyong.com/hibernate/hibernate-many-to-many-example-join-table-extra-column-annotation/

0 个答案:

没有答案