Spring级联字段未更新

时间:2015-05-22 10:11:22

标签: spring hibernate many-to-many

我有一个具有以下属性的对象,但是当我尝试保存对象时,此字段未合并。 我该如何解决这个问题?

$str = "'".implode("'".','."'", array_keys( $my_array ))."'";
// add single quote to each value    

$query = db_select('dog', 'dg')
  ->fields('dg')
  ->condition('numbers', $str, 'IN');

userSites:

@ManyToMany(targetEntity = User.class, mappedBy = "userSites", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@NotAudited
private List<IUser> localIt;

1 个答案:

答案 0 :(得分:0)

而不是保存属性:

@ManyToMany(targetEntity = User.class, mappedBy = "userSites", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@NotAudited
private List<IUser> localIt;

我通过添加网站注册到相关字段来更新每个用户的网站列表:

@BatchSize(size = 20)
@ManyToMany(cascade = { CascadeType.MERGE, CascadeType.PERSIST }, fetch = FetchType.LAZY,targetEntity=Site.class)
@JoinTable(name = "USER_SITE",
joinColumns = { @JoinColumn(name = USER_ID, nullable = false) },
inverseJoinColumns = { @JoinColumn(name = "SITE_ID", nullable = false) })
private Set<ISite> userSites;