请帮我解决这个问题。我尝试使用谷歌搜索解决方案而无法找到解决方案。
表:目录 catalog_id(主键) 名称
表:Catalog_Locale catalog_id LOCALE_ID 序列 复合键(catalog_id,locale_id)
公共类目录{
@Id
@Column(name = "CATALOG_ID", nullable = false)
private String catalogId;
@Column(name = "NAME")
private String name;
@OneToMany(targetEntity = CatalogLocale.class,fetch=FetchType.LAZY)
@JoinColumn(name = "CHILD_CATALOG_ID", nullable = false)
@Cascade(value = {})
protected List<CatalogLocale> locales = new ArrayList<CatalogLocale>(10);
public void setCatalogId( String catalogId ){
this.catalogId = catalogId;
}
public void setName( String name ){
this.name = name;
}
public void setLocales( List<CatalogLocale> locales ){
this.locales = locales;
}
public void getCatalogId(){
return catalogId;
}
public void getName(){
return name;
}
public void getLocales(){
return locales;
}
}
公共类CatalogLocale {
@EmbeddedId
CatalogLocalePk catalogLocalePk;
@Column(name = "SEQUENCE")
private int sequence;
public void setCatalogLocalePk( CatalogLocalePk catalogLocalePk ){
this.catalogLocalePk = catalogLocalePk;
}
public void setSequence( int sequence ){
this.sequence = sequence;
}
public CatalogLocalePk getCatalogLocalePk(){
return catalogLocalePk;
}
public int getSequence(){
return sequence;
}
@Embeddable
public static class CatalogLocalePk{
@Column(name = "CATALOG_ID", nullable = false)
private String catalogId;
@Column(name = "LOCALE_ID", nullable = false)
private String localeId;
public CatalogLocalePk(){
}
public CatalogLocalePk( String catalogId, String localeId ){
this.catalogId = catalogId;
this.localeId = localeId;
}
public void setCatalogId( String catalogId ){
this.catalogId = catalogId;
}
public void setLocaleId( String localeId ){
this.localeId = localeId;
}
public String getCatalogId(){
return catalogId;
}
public String getLocaleId(){
return localeId;
}
}
}
该代码适用于插入操作,但对于目录的任何更新都将触发删除并重新插入子表的所有条目。
有没有解决方案?