I'm having a problem with a class that has multiple collections of the same base type. I think the problem is that it's not applying the discriminator in the WHERE clause.
Collections:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "document", fetch = FetchType.EAGER)
public List<Signer> getSigners() {
return signers;
}
@OneToMany(cascade = CascadeType.ALL, mappedBy="document")
public List<Observer> getObservers() {
if(observers == null) observers = new ArrayList();
return observers;
}
Here is the SQL output:
Hibernate: select document0_.id as id3_, document0_.createdDate as createdD2_3_, document0_.description as descript3_3_, document0_.dueDate as dueDate3_, document0_.lastModifiedDate as lastModi5_3_, document0_.name as name3_, document0_.owner_id as owner7_3_ from Document document0_ where document0_.owner_id=?
SQL for getting the first signers collection (trimmed for ease of reading):
Hibernate: select signers0_.document_id as document7_3_
......
where signers0_.document_id=?
Notice there is not discriminator in the where clause.
So it ends up throwing this exception. In the database, the signed value is set for all DTYPE="Signer".
javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.middlepost.signer.model.Signer.signed
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:630)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:75)
Am I missing something? Thanks in advance.
|