-->
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.  [ 3 posts ] 
Author Message
 Post subject: Property Access Exception inside setter of list
PostPosted: Mon Jul 31, 2006 6:09 pm 
Newbie

Joined: Thu Feb 16, 2006 2:18 pm
Posts: 4
Location: Colorado
I am getting an org.hibernate.PropertyAccessException on the following simple code using the HQL scratch pad in Eclipse.

Here is the error as it reads:

org.hibernate.PropertyAccessException: Exception occured inside setter of com.rock.common.domain.dto.SpecificationDO.specValues

Here is the HQL:

from SpecificationDO as s left join fetch s.specValues

The Specification Table has a one to many relationship with the specvalue table.

The specvalue table uses an id reference to the specification table.


Here is the setter inside of the SpecificationDO:

private ArrayList specvalues = null;

public SpecificationDO() {
specValues = new ArrayList();
}

public void setSpecValues(Collection x) {
this.specValues.clear();
this.specValues.addAll(x);
}

Thanks in advance

Hibernate version: 3.1

Mapping documents:

<bag
name="specValues"
lazy="false"
inverse="true"
cascade="none"
order-by="sort asc"
>
<cache
usage="read-write"
/>

<key
column="specificationId"
>
</key>

<one-to-many
class="com.rock.common.domain.dto.SpecValueDO"
/>

</bag>

Code between sessionFactory.openSession() and session.close():

n/a ... using eclipse tools

Full stack trace of any exception that occurs:

org.hibernate.PropertyAccessException: Exception inside of setter of com.rock.common.domain.dto.SpecificationDO.specValues

Name and version of the database you are using:

PostgreSQL v.8.1

The generated SQL (show_sql=true):

SQL #0 types: com.rock.common.domain.dto.SpecificationDO
-----------------
select
specificat0_.specificationid as specific1_37_0_,
specvalues1_.specvalueid as specvalu1_38_1_,
specificat0_.name as name37_0_,
specificat0_.sort as sort37_0_,
specificat0_.productId as productId37_0_,
specvalues1_.name as name38_1_,
specvalues1_.value as value38_1_,
specvalues1_.sort as sort38_1_,
specvalues1_.specificationId as specific5_38_1_,
specvalues1_.specificationId as specific5_0__,
specvalues1_.specvalueid as specvalu1_0__
from
specification specificat0_
left outer join
specvalue specvalues1_
on specificat0_.specificationid=specvalues1_.specificationId
order by
specvalues1_.sort asc

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 6:51 pm 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
Code:
public void setSpecValues(Collection x) {
this.specValues.clear();
this.specValues.addAll(x);
}


why are you doing that instead of

Code:
public void setSpecValues(Collection x) {
this.specValues = x

}

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 7:32 pm 
Newbie

Joined: Thu Feb 16, 2006 2:18 pm
Posts: 4
Location: Colorado
Either way, it does not matter. Having instantiated the variable (specValues) as an ArrayList, to the best of my knowledge the code that you suggest will not work. Hence I have done it the way that I have.

Nonetheless, what is odd is when I am using criteria queries, I do not get the same error implying that it is may be some sort of casting error.


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

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.