tags:

views:

100

answers:

0

I have the following relationships in my entity table

Table A

@OneToMany(mappedBy = "A", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Cascade(value = DELETE_ORPHAN)
@OrderBy
private List<B> orders = new ArrayList<B>(0);

@OneToMany(mappedBy = "A", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Cascade(value = DELETE_ORPHAN)
private List<C> values = new ArrayList<C>(0);

Table C

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "a_id", nullable = false, referencedColumnName = "id")
@NotNull
private A a;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "b_id", nullable = false, referencedColumnName = "id")
@NotNull
private B b;

Note: Table C contains a foreign key relationship to B also

A aInstance; If i try to delete "A" (using entityManager.remove(aInstance)) it throws an error mentioning that a null value is passed for delete while trying to removing the children.

How do I get around this issue?