MobeeCustomer と CustomerRegion の 2 つのエンティティがあります。最初に CustomerRegion からオブジェクトを削除したいのですが、CustomerRegion の列に参加するのは null です。次に、entityManager からオブジェクトを削除しますが、例外が発生します。
Mobeeお客様:
public class MobeeCustomer implements Serialization{ private Long id; private String custName; private String Address; private String phoneNo; private Set<CustomerRegion> customerRegion = new HashSet<CustomerRegion>(0); @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, fetch = FetchType.LAZY, mappedBy = "mobeeCustomer") public Set<CustomerRegion> getCustomerRegion() { return CustomerRegion; } public void setCustomerRegion(Set<CustomerRegion> customerRegion) { CustomerRegion = customerRegion; } }
顧客地域
public class CustomerRegion implements Serializable{
private Long id;
private String custName;
private String description;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
private MobeeCustomer mobeeCustomer;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "MOBEE_CUSTOMER")
public MobeeCustomer getMobeeCustomer() {
return mobeeCustomer;
}
public void setMobeeCustomer(MobeeCustomer mobeeCustomer) {
this.mobeeCustomer = mobeeCustomer;
}
}
サンプルコード:
if (doUpdateRegion.getStatus().equals(UserOperations.DELETE.getType())) {
custEntity = getEntityManager().find(CustomerRegion.class,doUpdateRegion.getId());
BeanUtils.copyProperties(custEntity, doUpdateRegion);
deletedRegionsList.add(custEntity);
}
for (CustomerRegion region : deletedRegionList) {
region.setMobeeCustomer(null);
getEntityManager().remove(region);
}
StackTrace:
please suggest me how to remove the CustomerRegion Object I am getting Exception
javax.persistence.EntityNotFoundException: deleted entity passed to persist: [com.manam.mobee.persist.entity.CustomerRegion#<null>]
15:46:34,614 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:613)
15:46:34,614 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:299)
15:46:34,614 ERROR [STDERR] at org.jboss.seam.persistence.EntityManagerProxy.flush(EntityManagerProxy.java:92)
15:46:34,614 ERROR [STDERR] at org.jboss.seam.framework.EntityHome.update(EntityHome.java:64)