Hibernate多对多生成null成员

时间:2015-10-22 14:35:39

标签: java hibernate many-to-many

我有两个实体类,在那些字段上有多对多关系。 他们在这里:

public class TCustomerProfile {
...
@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.MERGE},mappedBy = "customers")
private List<TUserProfile> users;
...
}
public class TUserProfile{
...
@JoinTable(name = "T_USER_AUTHORIZATION", 
        joinColumns = {@JoinColumn(name = "USER_ID" ,referencedColumnName ="USER_ID")/*,@JoinColumn(name = "ENTITY1" ,referencedColumnName ="ENTITY")*/ }, 
        inverseJoinColumns = { @JoinColumn(name = "CUSTOMER_ID" ,referencedColumnName ="CUSTOMER_ID")/*,@JoinColumn(name = "ENTITY" ,referencedColumnName ="ENTITY")*/} )
@ManyToMany(fetch = FetchType.EAGER)
private List<TCustomerProfile> customers;
...
}

现在的问题是:
TCustomerProfile.users中的某个用户null是如何成为可能的呢? 这三个表(包括join table t_user_authorization)中的某些数据组合会导致这种情况吗?

0 个答案:

没有答案