以下代码使用“Propriedade”和“doc_id”字段生成一个表格,其中存在PK约束。
我想知道可以用来指定PK的最合适的注释是什么?
public class Documento {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
private long id;
private String numero;
private TipoDeMidia midia;
private String nomeDoArquivo;
@ElementCollection
@MapKeyColumn(name="propriedade")
@Column(name="valor")
@CollectionTable(name="DOCINFO",joinColumns=@JoinColumn(name="doc_id"))
private Map<String,String> informacoesDoDocumento= new HashMap<String, String>();
这是SQL生成的
CREATE TABLE docinfo
(
doc_id bigint NOT NULL,
valor character varying(255),
propriedade character varying(255) NOT NULL,
CONSTRAINT docinfo_pkey PRIMARY KEY (doc_id, propriedade),
CONSTRAINT fk97c919c6e3b42d44 FOREIGN KEY (doc_id)
REFERENCES documento (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)