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 traceCode:
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)