I have two entities like the below: Device:
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "device")
private Set<DeviceLine> deviceLines;
DeviceLine:
@ManyToOne
@JoinColumn(name = "device_uid")
private Device device;
DeviceComponent Manager.Class:
DeviceLinePersistenceManager dlpm = new DeviceLinePersistenceManager();
try {
dpm = new DevicePersistenceManager();
Set<DeviceLine> set = new HashSet<DeviceLine>();
for (LineStatus lineStatus : list) {
Device deviceRetrieval = dpm.findDeviceByIp(lineStatus
.getDeviceIp());
if (deviceRetrieval != null) {
Set<DeviceLine> set1 = deviceRetrieval.getDeviceLines();
if (!set1.isEmpty()) {
Iterator<DeviceLine> iterator = set1.iterator();
while (iterator.hasNext()) {
DeviceLine line = iterator.next();
iterator.remove();
DeviceLine lineToDeleted = dlpm.find(line.getUid());
dlpm.purge(lineToDeleted.getUid());
}
}
dpm.update(deviceRetrieval);
}
}
when the run the above code iam getting the ObjectDeletedException: deleted entity passed to persist.
i am unable to delete the deviceline entries. The exception is thrown when dlpm.purge(..) is called,help me out.