-->
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: PropertyAccessException from criteria.uniqueResult();
PostPosted: Wed Jul 20, 2005 4:37 pm 
Newbie

Joined: Wed Jul 20, 2005 4:17 pm
Posts: 3
Hello,

Thank you for any help in advance. I am new to Hibernate, but I've searched through the forums and couldn't find anything relevant.

I am trying to obtain the Article object based on the given criteria using the Java below. The exception is thrown from the crit.uniqueResult() line. I am not sure what is going on. Please post if I need to provide more information. Below is the information as required by the forum. Thanks so much.

ESHAGGY


Hibernate version:
3.0.5
Mapping documents:
<class name="cmp.repository.article.Article" table="ARTICLE">
<id name="artID" type="int" column="ART_ID">
<generator class="sequence">
<param name="sequence">article_sequence</param>
</generator>
</id>

<!-- property name="siteID" type="int">
<column name="SITE_ID" />
</property -->

<!-- many-to-one name="cmp.repository.article.Site"
column="SITE_ID"
not-null="true" / -->

<property name="createSiteID" type="int">
<column name="CREATE_SITE_ID" />
</property>

<property name="languageID" type="int">
<column name="LANGUAGE_ID" />
</property>

<property name="desc" type="string" >
<column name="DESCRIPTION" />
</property>

<property name="publishDate" type="date" >
<column name="PUBLISH_DATE" />
</property>

<property name="headline" type="string" >
<column name="HEADLINE" />
</property>

<list name="bodies" lazy="true">
<key>
<column name="ART_ID"></column>
</key>
<index column="PAGE_NUMBER" type="int" />
<one-to-many class="cmp.repository.article.Body"/>
</list>
</class>

Code between sessionFactory.openSession() and session.close():
Session session = HibernateUtils.getSession();
Criterion artEq = Expression.idEq(new Integer(artID));
Criteria crit = session.createCriteria(Article.class);
crit.add(artEq);
Article a = (Article)crit.uniqueResult();

Full stack trace of any exception that occurs:

Exception in thread "main" org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of cmp.repository.article.Article.setBodies
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:203)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:173)
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
at org.hibernate.loader.Loader.doQuery(Loader.java:436)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1322)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
at cmp.repository.article.ArticleRetriever.getArticleBodiesByID(ArticleRetriever.java:52)
at cmp.repository.article.ArticleRetriever.main(ArticleRetriever.java:59)
Caused by: net.sf.cglib.beans.BulkBeanException: org.hibernate.collection.PersistentList
at cmp.repository.article.Article$$BulkBeanByCGLIB$$426ed50e.setPropertyValues(<generated>)
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:200)
... 13 more
Caused by: java.lang.ClassCastException: org.hibernate.collection.PersistentList
... 15 more

Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
select this_.ART_ID as ART1_0_, this_.CREATE_SITE_ID as CREATE2_1_0_, this_.LANGUAGE_ID as LANGUAGE3_1_0_, this_.DESCRIPTION as DESCRIPT4_1_0_, this_.PUBLISH_DATE as PUBLISH5_1_0_, this_.HEADLINE as HEADLINE1_0_ from ARTICLE this_ where this_.ART_ID = ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 5:29 pm 
Newbie

Joined: Wed Jul 20, 2005 4:17 pm
Posts: 3
Here's an updated mapping file:

<class name="cmp.repository.article.Article" table="ARTICLE">
....
<list name="bodies" table="ARTICLE_BODY">
<key column="ART_ID"/>
<index column="PAGE_NUMBER" type="int" />
<many-to-many class="cmp.repository.article.Body" column="BODY_ID"/>
</list>
</class>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 5:39 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
eshaggy wrote:
Here's an updated mapping file:

<class name="cmp.repository.article.Article" table="ARTICLE">
....
<list name="bodies" table="ARTICLE_BODY">
<key column="ART_ID"/>
<index column="PAGE_NUMBER" type="int" />
<many-to-many class="cmp.repository.article.Body" column="BODY_ID"/>
</list>
</class>


What does your Article java class look like ?


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.