@Entity
@Access(AccessType.FIELD)
public class D2 {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private int id;
@ManyToOne
@JoinColumn(name = "customerId", nullable = false)
private Customer customer;
}
@Entity
public abstract class AbstractD2Source {
...
@OneToOne(optional = true)
@JoinColumn(name = "dId", nullable = true)
private D2 d;
...
}
CriteriaDelete<AbstractD2Source> query = cb.createCriteriaDelete(AbstractD2Source.class);
Root<AbstractD2Source> dSource = query.from(AbstractD2Source.class);
query.where(cb.and(
cb.equal(dSource.get(AbstractD2Source_.datafeed).get(D2_.customer), customer),
datafeedSource.get(AbstractD2Source_.id).in(dSourceIds)
));
return em.createQuery(query).executeUpdate();