-->
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.  [ 11 posts ] 
Author Message
 Post subject: error accessing data
PostPosted: Thu Mar 17, 2005 4:48 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
Hi all,

what does this error mean :

Code:
org.hibernate.PropertyAccessException: could not set a field value by reflection setter (here classname)


How can I manage this problem?

_________________
bimki


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 5:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
by making a set that matchs what your mapping states or vice versa.

you have some property listed without having the propper setter.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 5:56 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
i have setter matched to this property. But maybye the problem is, that this setter is for my type (it comes from 1:1 association)?

_________________
bimki


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 6:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dont understand what you are writing.

but yes - the type must also match.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 6:19 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
max wrote:
you have some property listed without having the propper setter.


I have prooper setter :



Code:
public class Modul extends com.bimki.oo7j.hibernate.om.ElementProjektowy implements java.io.Serializable {

    // Fields   
    private com.bimki.oo7j.hibernate.om.Manual manual;
    private com.bimki.oo7j.hibernate.om.ZestawZlozony glownyZlozony;
    private java.util.Set zestawyZlozone;

(......)

   public void setGlownyZlozony (com.bimki.oo7j.hibernate.om.ZestawZlozony glownyZlozony) {
       this.glownyZlozony = glownyZlozony;
    }


and error :

org.hibernate.PropertyAccessException: could not set a field value by reflection setter of com.bimki.oo7j.hibernate.om.Modul.glownyZlozony

_________________
bimki


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 6:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
show mapping and full stack trace please

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 6:34 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
Mapping file :

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
   <!-- http://hibernate.sourceforge.net/-->
<hibernate-mapping default-access="field">
   <!--Dokument-->
   <class name="com.bimki.oo7j.hibernate.om.Dokument" table="Dokument">
      <id name="id" column="dok_id" type="integer" unsaved-value="null">
         <generator class="foreign">
            <param name="property">czescZlozona</param>
         </generator>
      </id>
      <property name="tekst" column="dok_tekst" type="string" />
      <property name="tytul" column="dok_tytul" type="string" length="40"
         index="IndexDokumentTytul" />
      <!-- relacja 1:1 z czescia zlozona-->
      <one-to-one name="czescZlozona"
         class="com.bimki.oo7j.hibernate.om.CzescZlozona"/>
   </class>
   <!--Manual-->
   <class name="com.bimki.oo7j.hibernate.om.Manual" table="Manual">
      <id name="id" column="man_id" type="integer" unsaved-value="null">
         <generator class="foreign">
            <param name="property">modul</param>
         </generator>
      </id>
      <property name="tytul" column="man_tytul" type="string" length="40" />
      <property name="tekst" column="man_tekst" type="string" />
      <property name="dlugoscTekstu" column="man_dlTekstu" type="integer"
         not-null="true" />
      <!-- relacja 1:1 z modulem -->
      <one-to-one name="modul" class="com.bimki.oo7j.hibernate.om.Modul"/>
   </class>
   <!--Polaczenie-->
   <class name="com.bimki.oo7j.hibernate.om.Polaczenie" table="Polaczenie">
      <id name="id" column="pol_id" type="integer" unsaved-value="null">
         <generator class="increment" />
      </id>
      <property name="dlugosc" column="pol_dlugosc" type="integer"
         not-null="true" />
      <property name="typ" column="pol_typ" type="string" length="10" />
      <!-- relacja 1:m  z czescia Atomowa -->
      <many-to-one name="zatomowej"
         class="com.bimki.oo7j.hibernate.om.CzescAtomowa" column="pol_czaZ"
         />
      <!-- relacja 1:m  z czescia Atomowa -->
      <many-to-one name="doatomowej"
         class="com.bimki.oo7j.hibernate.om.CzescAtomowa" column="pol_czaDo"
         />
   </class>
   <!--Element projektowy-->
   <class name="com.bimki.oo7j.hibernate.om.ElementProjektowy"
      table="ElementProjektowy">
      <id name="id" column="ep_id" type="integer" unsaved-value="null">
         <generator class="increment" />
      </id>
      <property name="typ" column="ep_typ" type="string" length="10" />
      <property name="data" column="ep_data" type="date" not-null="true" />
      <!--Czesc atomowa-->
      <joined-subclass name="com.bimki.oo7j.hibernate.om.CzescAtomowa"
         table="CzescAtomowa">
         <key column="cza_id" />
         <property name="x" column="cza_x" type="integer" not-null="true" />
         <property name="y" column="cza_y" type="integer" not-null="true" />
         <property name="dokId" column="cza_dokId" type="integer"
            not-null="true" />
         <!-- relacja 1:m  z czescia zlozona -->
         <many-to-one name="czescZlozona"
            class="com.bimki.oo7j.hibernate.om.CzescZlozona"
            column="cza_czId" />
         <!-- relacja 1:m  z polaczeniem -->
         <set name="polaczenieDo" lazy="true">
            <key column="cza_zAtomowej" />
            <one-to-many class="com.bimki.oo7j.hibernate.om.Polaczenie" />
         </set>
         <!-- relacja 1:m  z polaczeniem -->
         <set name="polaczenieZ" lazy="true">
            <key column="cza_doAtomowej" />
            <one-to-many class="com.bimki.oo7j.hibernate.om.Polaczenie" />
         </set>
      </joined-subclass>
      <!--Czesc zlozona-->
      <joined-subclass name="com.bimki.oo7j.hibernate.om.CzescZlozona">
         <key column="czz_id"/>
         <!-- relacja m:n  z zestawem podstawowym -->
         <bag name="zestawyPodstawowe" table="CzzZp" lazy="true">
            <key column="CzZp_czzId" />
            <many-to-many
               class="com.bimki.oo7j.hibernate.om.ZestawPodstawowy"
               column="CzZp_zpId" />
         </bag>
         <!-- relacja 1:1  z dokumentem -->
         <one-to-one name="dokument"
            class="com.bimki.oo7j.hibernate.om.Dokument"
            foreign-key="dokument"/>
         <one-to-one name="glownaAtomowa"
            class="com.bimki.oo7j.hibernate.om.CzescAtomowa"/>
         <!-- relacja 1:m  z czescia atomowa -->
         <set name="czesciAtomowe" lazy="true">
            <key column="czz_czaId" />
            <one-to-many class="com.bimki.oo7j.hibernate.om.CzescAtomowa" />
         </set>
      </joined-subclass>
      <!--Modul-->
      <joined-subclass name="com.bimki.oo7j.hibernate.om.Modul">
         <key column="mod_id" />
         <!-- relacja 1:1  z manualem -->
         <one-to-one name="manual"
            class="com.bimki.oo7j.hibernate.om.Manual"
            foreign-key="manual"/>
         <one-to-one name="glownyZlozony"
            class="com.bimki.oo7j.hibernate.om.ZestawZlozony"
            cascade="all"/>
         <set name="zestawyZlozone" lazy="true">
            <key column="mod_id" />
            <one-to-many class="com.bimki.oo7j.hibernate.om.ZestawZlozony"
               />
         </set>
      </joined-subclass>
      <!--Zestaw podstawowy-->
      <joined-subclass name="com.bimki.oo7j.hibernate.om.ZestawPodstawowy">
         <key column="zp_id" />
         <!-- relacja m:n  z czescia zlozona -->
         <bag name="czesciZlozone" table="CzzZp" inverse="true" lazy="true">
            <key column="CzZp_zpId" />
            <many-to-many class="com.bimki.oo7j.hibernate.om.CzescZlozona"
               column="CzZp_czzId" />
         </bag>
      </joined-subclass>
      <!--Zestaw zlozony-->
      <joined-subclass name="com.bimki.oo7j.hibernate.om.ZestawZlozony">
         <key column="zz_id" />
         <!-- relacja 1:m  zmodul -->
         <many-to-one name="modul" class="com.bimki.oo7j.hibernate.om.Modul"
            column="zz_modId" />
         <!-- relacja 1:m  z zestawem zlozonym -->
         <set name="zestawyZlozone" lazy="true">
            <key column="zz_zzId" />
            <one-to-many class="com.bimki.oo7j.hibernate.om.ZestawZlozony"
               />
         </set>
         <set name="zestawyPodstawowe" lazy="true">
            <key column="zz_zpId" />
            <one-to-many
               class="com.bimki.oo7j.hibernate.om.ZestawPodstawowy" />
         </set>
      </joined-subclass>
   </class>
</hibernate-mapping>



full stack trace


Code:
org.hibernate.PropertyAccessException: could not set a field value by reflection setter of com.bimki.oo7j.hibernate.om.Modul.glownyZlozony
   at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:74)
   at org.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:564)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:107)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:428)
   at org.hibernate.loader.Loader.doQuery(Loader.java:390)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:195)
   at org.hibernate.loader.Loader.doList(Loader.java:1360)
   at org.hibernate.loader.Loader.list(Loader.java:1343)
   at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:872)
   at org.hibernate.impl.SessionImpl.find(SessionImpl.java:973)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
   at com.bimki.oo7j.experiments.Hibernate.nawigacja1(Hibernate.java:82)
   at com.bimki.oo7j.experiments.Hibernate.service(Hibernate.java:56)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
   at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException
   at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)
   at java.lang.reflect.Field.set(Unknown Source)
   at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:71)
   ... 36 more


I have this error, when I try to submit "from Modul" HQL Query.


this is (or should be :) ) 1:1 association between Modul and ZestawZlozony classes (bidirectional)

_________________
bimki


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 6:25 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
mabye I'll show You how am I going to access the data :

Code:
           
            session = factory.openSession();
            tx = session.beginTransaction();
            time = System.currentTimeMillis();

            Query q = session.createQuery("from Modul");
            q.setMaxResults(1);
            List moduly = null;
            moduly = q.list(); //  <<<<< [b] here exception is thrown [/b]
            tx.commit();



thanks for help!

_________________
bimki


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 8:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm....dont know what UnsafeObjectFieldAccessorImpl check since it complains.....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 20, 2005 7:34 am 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
can You check if the bidirectional 1:1 association between Modul and CzescZlozona is mapped good?

max wrote:
hmm....dont know what UnsafeObjectFieldAccessorImpl check since it complains.....


Belive me - I tried and din'f found any reason :(

_________________
bimki


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 10:35 am 
Newbie

Joined: Thu Apr 26, 2007 10:32 am
Posts: 1
Hibernate requires that collection-valued properties be typed to an interface such as java.util.Set or java.util.List and not to an actual implementation such as java.util.HashSet (this is a good practice anyway).

Maybe this is the reason for your exception!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 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.