开发者

Seam hibernate delete orphan problem

开发者 https://www.devze.com 2023-02-09 08:33 出处:网络
Im using an entity Employee and inside that a list of UserMaster is defined public class EmployeeMaster{

Im using an entity Employee and inside that a list of UserMaster is defined

public class EmployeeMaster{
    private String employee_id;
    private String first_name;
    private String last_name;
    private List<UserMaster> userMaster = new ArrayList<UserMaster>();

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "employeeMaster")
    @Cascade(value = {CascadeType.SAVE_UPDATE,CascadeType.DELETE_ORPHAN})   
    public  List<UserMaster> getUserMaster() {
        return userMaster;
    }
    public void setUserMaster(List<UserMaster> userMaster) {
        this.userMaster = userMaster;
    }
}

in my method im calling

xsession.saveOrUpdate(employeeMaster);

Here im clearing previous child collection explicitly and add new Child objects

But the delete orphan is not working her开发者_Go百科e .. Only the insert query is running Pls Help

A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity

message is showing in the console


It looks like you replaced the collection contained in the loaded entity with setUserMaster().

When collection is configured with DELETE_ORPHAN, you cannot replace the collection this way, you need to modify the existing collection using its own methods.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号