I have two custom classes and devices.
User object:
public class User {
private Long userId;
@OneToMany( mappedBy = "userId", fetch = FetchType.LAZY)
private Collection<Device> deviceCollection;
and device object:
public class Device implements Serializable {
@JoinColumn(name = "user_id", referencedColumnName = "user_id")
@ManyToOne(optional = false, fetch = FetchType.LAZY)
private User userId;
When I merge a previously disconnected device object in the entity manager after the parent user has been deleted, both the user (previously deleted) and the device are reinserted into the database. There is no cascading annotation for the user or device; therefore, I do not expect the user object to be reinserted, but it did;
How to prevent cascade merge operation for custom object?
Thanks in advance.
eymlo source
share