-->
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: two joined subclass : one-to-one association
PostPosted: Sat Mar 05, 2005 11:28 am 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
Hibernate version: 2.1.7c

Mapping documents:


Code:

   <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"/>
      <!--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"/>
         <one-to-one name="glownyZlozony" property-ref="zz_id"
            class="com.bimki.oo7j.hibernate.om.ZestawZlozony"/>            
         <set name="zestawyZlozone" lazy="true">
            <key column="mod_id"/>
            <one-to-many class="com.bimki.oo7j.hibernate.om.ZestawZlozony"/>
         </set>
      </joined-subclass>
      <!--Zestaw zlozony-->
      <joined-subclass name="com.bimki.oo7j.hibernate.om.ZestawZlozony">
         <key column="zz_id"/>
         <!-- relacja 1:m  z modul -->
         <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>



Name and version of the database you are using: mySQL 4.1x

The generated SQL (show_sql=true): true


why

Code:
   <one-to-one name="glownyZlozony" property-ref="zz_id"
            class="com.bimki.oo7j.hibernate.om.ZestawZlozony"/>   


doesn't work?
How should I write in mapping document association 1:1 between 2 joined-subclasses?

thanks for any help!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 30, 2005 1:44 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
the same problem in Hibernate 3.

I tried to do It also with foreign-key :
Quote:
<one-to-one name="glownyZlozony" foreign-key="mod_gl_zl_id"
class="com.bimki.oo7j.hibernate.om.ZestawZlozony" />


but I always got following error :

Quote:
Hibernate: select modul0_.mod_id as ep_id3_, modul0_1_.ep_typ as ep_typ3_3_, modul0_1_.ep_data as ep_data3_3_, manual1_.man_id as man_id0_, manual1_.man_tytul as man_tytul1_0_, manual1_.man_tekst as man_tekst1_0_, manual1_.man_dlTekstu as man_dlTe4_1_0_, modul2_.mod_id as ep_id1_, modul2_1_.ep_typ as ep_typ3_1_, modul2_1_.ep_data as ep_data3_1_, zestawzloz3_.zz_id as ep_id2_, zestawzloz3_1_.ep_typ as ep_typ3_2_, zestawzloz3_1_.ep_data as ep_data3_2_, zestawzloz3_.mod_id as mod_id9_2_, zestawzloz3_.zz_zzId as zz_zzId9_2_ from Modul modul0_ inner join ElementProjektowy modul0_1_ on modul0_.mod_id=modul0_1_.ep_id left outer join Manual manual1_ on modul0_.mod_id=manual1_.man_id left outer join Modul modul2_ on manual1_.man_id=modul2_.mod_id left outer join ElementProjektowy modul2_1_ on modul2_.mod_id=modul2_1_.ep_id left outer join ZestawZlozony zestawzloz3_ on modul0_.mod_id=zestawzloz3_.zz_id left outer join ElementProjektowy zestawzloz3_1_ on zestawzloz3_.zz_id=zestawzloz3_1_.ep_id where modul0_.mod_id=?
19:37:36,080 WARN PersistenceContext:458 - Narrowing proxy to class com.bimki.oo7j.hibernate.om.ZestawZlozony - this operation breaks ==
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)



what am I doing wrong? Is it possible to have one to one-to-one association between two joined subclasses?

I don't have problems with saving data, but only fetching it... Perhabs some data is not beeing saved?

_________________
bimki


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 24, 2005 12:50 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
I still can't solve this problem :(

Please, give me some suggestion...

_________________
bimki


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.