我在域类(JPA)中完成了代码更改。我向一个实体添加了一个ElementCollection:
@ElementCollection(targetClass = String.class)
@CollectionTable(name = "T_NETWORK_STATE", joinColumns = {@JoinColumn(name = "NETWORK_ID")})
@Column(name = "STATE")
private Set<String> states = new HashSet<>();
现在我想为此更改编写一个flyway更新数据库脚本。我需要表T_NETWORK_STATE的SQL DDL。
我是编写SQL查询的新手。任何帮助将不胜感激!
答案 0 :(得分:1)
CREATE TABLE T_NETWORK_STATE (
NETWORK_ID INT,
STATE VARCHAR(100),
UNIQUE INDEX (NETWORK_ID, STATE),
FOREIGN KEY (NETWORK_ID) REFERENCES NETWORK(NETWORK_ID)
);