These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Inheritance with multiple OneToMany collections
PostPosted: Tue Apr 24, 2007 12:56 am 
Beginner
Beginner

Joined: Sat Aug 30, 2003 1:36 am
Posts: 47
Location: Calgary, AB
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.