次のエンティティがあります。Car
とManyToManyの関係がありHuman
ます。車とユーザーの間で補助クラスAssignを使用しています
@Entity
public class Car implements Serializable
{
//...
@LazyCollection(LazyCollectionOption.TRUE)
@OneToMany(cascade = CascadeType.ALL, mappedBy = "car")
private Set<Assign> cars = new HashSet<Assign>();
//...
}
@Entity
class Assign implements Serializable
{
//...
@LazyCollection(LazyCollectionOption.FALSE)
@ManyToOne
@JoinColumn(name = "HUMAN_CAR", nullable = false)
private Human human;
@LazyCollection(LazyCollectionOption.FALSE)
@ManyToOne
@JoinColumn(name = "CAR_HUMAN", nullable = false)
private Car car;
//..
}
@Entity
public class Human implements Serializable
{
//...
@LazyCollection(LazyCollectionOption.TRUE)
@OneToMany(cascade = CascadeType.ALL, mappedBy = "human")
private Set<Assign> cars = new HashSet<Assign>();
// ...
}
今、私はコンテナ管理トランザクション内の車を削除しようとしています
public void deleteCar(final long id)
{
final Car car = entityManager.find(roleId, Car.class);
entityManager.remove(car);
}
しかし、私は得る
Caused by: javax.persistence.EntityNotFoundException: deleted entity passed to persist: [com.dto.Assign#<null>]