Hi,

> -----Urspr�ngliche Nachricht-----
> Von: Andrey Chernyh [mailto:[EMAIL PROTECTED]]
> Gesendet: Mittwoch, 28. August 2002 14:49
> An: OJB Users List
> Betreff: Have problem with complicated mapping + proxy
> 
> 
> Hi!
> 
> Short description of the problem:
> making field "proxy" causes exception when loading an object.
> 
> 
> I need advice on following situation:
> There are 4 types of objects:
> User,  mapped to table "user"
> System, mapped to table "stored_object"
> Client, mapped to table "stored_object"
> Reseller, mapped to table "stored_object"
> 
> 3 last objects are mapped to one table, because User has field called
> "parent", and the parent can be of one of the 3 types.
> 
> For using proxy, they all implement their interface.
> UserImpl implements User,
> StoredObject implements StoredObjectInterf,
> SystemImpl extends StoredObject,implements System,
> ClientImpl extends StoredObject,implements Client,
> ResellerImpl extends StoredObject,implements Reseller,
> 
> Mapping:
> <class-descriptor class="User">
>       <extent-class class-ref="UserImpl" />
> </class-descriptor>
> 
> <class-descriptor class="System">
>       <extent-class class-ref="SystemImpl" />
> </class-descriptor>
> 
> <class-descriptor class="Reseller">
>       <extent-class class-ref="ResellerImpl" />
> </class-descriptor>
> 
> <class-descriptor class="Client">
>       <extent-class class-ref="ClientImpl" />
> </class-descriptor>
> 
> 
> <class-descriptor  class="StoredObjectInterf">
>       <extent-class class-ref="StoredObject" />
>       <extent-class class-ref="SystemImpl" />
>       <extent-class class-ref="ClientImpl" />
>       <extent-class class-ref="ResellerImpl" />
> </class-descriptor>
> 
> <class-descriptor  class="StoredObject">
>       <extent-class class-ref="SystemImpl" />
>       <extent-class class-ref="ClientImpl" />
>       <extent-class class-ref="ResellerImpl" />
> </class-descriptor>
> 
> <class-descriptor class="UserImpl" proxy="dynamic"  table="user">
>     <field-descriptor id="1" name="id" column="id" 
> jdbc-type="INTEGER" primarykey="true" autoincrement="true"/>
>     <field-descriptor id="2" name="parentId" 
> column="parent_id" jdbc-type="INTEGER"/>
> 
>     <reference-descriptor name="parent"
>     >>>>>proxy="true"<<<<!!!Attention, critical place!
>      class-ref="StoredObject">
>         <foreignkey field-id-ref="2"/>
>     </reference-descriptor>
> </class-descriptor>
> ==============================================================
> ===============================

The mapping looks OK !

> My object of type UserImpl has parent of type SystemImpl.
> The problem is:
> When I load UserImpl without using proxy for "parent" field, it's OK
> When I load object by Identity , I see an exception:
> I know, that it occures, when trying to call BSUserImpl.setParent(
> Proxy ) ,

This error indicates that OJB can not assign a proxy object (which
implements the StoredObjectInterf) to the attribute
parent.
Make sure the parent attribute is of type StoredObjectInterf.

cheers,
Thomas

> java.lang.IllegalArgumentException: field type mismatch
>         at java.lang.reflect.Field.set(Native Method)
>         at 
> org.apache.ojb.broker.metadata.PersistentFieldDefaultImpl.set(
PersistentFieldDefaultImpl.java:146)
>         at 
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveR
> eference(PersistenceBrokerImpl.java:878)
>         at 
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveR
> eferences(PersistenceBrokerImpl.java:851)
>         at 
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getDBObje
> ct(PersistenceBrokerImpl.java:1479)
>         at 
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getObject
> ByIdentity(PersistenceBrokerImpl.java:1562)
> 
> Maybe I do something wrong?
> Or you can explain, how to handle this object scheme correctly in
> theory? I read all the documentation and made mapping according to it.
> -- 
> Best regards,
>  Andrey                            mailto:[EMAIL PROTECTED]
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to