I’m a bit unfamiliar with the terms necessary to ask this question, but we’ll see if I can get it right.
I have a JPA Entity that represents a joining of several other Entities, which is called UserJump:
@Entity
public class UserJump extends Model{
@ManyToOne
public User user;
@ManyToOne
public JumpSession jumpSession;
@ManyToOne
public Parachute parachute;
}
I have a JumpSession class that refers back to UserJump:
@Entity
public class JumpSession extends GenericModel{
@OneToMany(mappedBy="jumpSession")
public List<UserJump> userJumps;
}
However, I need to be able to delete JumpSession objects while retaining any UserJump objects that refer to them(right now I get a ConstraintViolationException when I call delete() on a JumpSession), since the UserJump object still links together other unique information. Ideally, the jumpSession variable in UserJump would be changed to null.
How can I do this?
You just need to modify the UserJump before deleting the JumpSession:
(note: the above is traditional Java Hibernate code. I don’t know how to translate that in Play’s way of doing)