JPA持久化List

阅读更多
List, List等类型不能直接用one-to-many够持久. 因为这些类型没有id. 为了持久话这些类型,需要把String或者是URL包装一下 例如下面的例子: @Entity public class RURL { String uuid; URL url; @Id @Column(nullable = false, updatable = false, length = 32) @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid") public String getUUID() { return uuid; } public void setUUID(String uuid) { this.uuid = uuid; } public URL getURL() { return url; } public void setURL(URL url) { this.url = url; } }

你可能感兴趣的:(JPA)