The proxies comment is irrelevant to the solution I noted.

You need to change:

        <reference-descriptor name="group"
class-ref="test.ojb.datamodel.Group" proxy="true" >

To:

        <reference-descriptor name="group"
class-ref="test.ojb.datamodel.GroupImpl" proxy="true" >



As far as my comment regarding proxies, in general we get better
performance by NOT proxying reference descriptors.  We do however
increase performance by proxying collection descriptors.  I would
suggest running tests both ways in your environment.

Wally

-----Original Message-----
From: Maksimenko Alexander [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 03, 2005 11:19 AM
To: OJB Users List
Subject: Re: ojb and interface driven design

thanks for idea but its unfortunately doesn't fit to me :( because i'm
need using proxies for perfomance reasons

of cause user a 1-m to group - but i created this example to simplify
understanding by problem - in real project my classes are big enough and
ojb descriptor is huge ;)


Gelhar, Wallace Joseph wrote:

>I've ran into this before.  I think the solution I found was to map the

>reference / collection descriptor classes to the implementing 
>descriptor as follows:
>
><class-descriptor 
>       class="test.ojb.datamodel.User">
>       <extent-class class-ref="test.ojb.datamodel.impl.UserImpl"/>
></class-descriptor><class-descriptor
>class="test.ojb.datamodel.impl.UserImpl" 
>       table="USER" 
>       factory-class="test.ojb.datamodel.impl.FactoryImpl"
>       factory-method="createUser">
>       <field-descriptor
>...
>       <reference-descriptor
>               name="group"
>               class-ref="test.ojb.datamodel.GroupImpl"
>               proxy="true"
>       >
>               <foreignkey field-ref="groupId"/>
>       </reference-descriptor> 
></class-descriptor>
>
><class-descriptor 
>       class="test.ojb.datamodel.Group">
>       <extent-class class-ref="test.ojb.datamodel.impl.GroupImpl"/>
></class-descriptor>
><class-descriptor 
>       class="test.ojb.datamodel.impl.GroupImpl" 
>       table="GROUP1" 
>       factory-class="test.ojb.datamodel.impl.FactoryImpl"
>       factory-method="createGroup">
>       <field-descriptor
>...
>       <reference-descriptor
>               name="manager"
>               class-ref="test.ojb.datamodel.UserImpl"
>               proxy="true"
>       >
>               <foreignkey field-ref="managerId"/>
>       </reference-descriptor> 
></class-descriptor>
>
>Also just note that it usually doesn't pay to proxy reference 
>descriptors since these can often be retrieved effeciently with one 
>query to the database.  Although it might make sense if you have a lot 
>of 1-1 relations that are not routinely used.  I usually proxy 
>collection descriptors though.
>
>The query for the interface class is perfectly fine.
>
>BTW is user really a 1-1 with group?  I would normally make this a 1-m 
>relation.
>
>Hope this helps.
>
>Wally
>
>-----Original Message-----
>From: Maksimenko Alexander [mailto:[EMAIL PROTECTED]
>Sent: Thursday, March 03, 2005 10:25 AM
>To: OJB Users List
>Subject: ojb and interface driven design
>
>hi!
>
>it's wondering but I found out that  its difficult to use interface 
>driven design with ojb ;( lets consider a simple 2-table example:
>
>interface User{Integer getId(),Group getGroup()}, class UserImpl 
>implements User{private Integer id; private Group group; access 
>methods}
>
>interface Group{Integer getId(),User getManager()}, class GroupImpl 
>implements Group{private Integer id;privarte User manager; access 
>methods}
>
>What repository descriptor should be to get correct results with the 
>following query:
>
>QueryByCriteria query = QueryFactory.newQuery(User.class,new
>Criteria());
>query.getCriteria().addEqualTo("group.manager.id",new Integer(4)); 
>Collection users = broker.getCollectionByQuery(query);
>
>Standard approach in mapping is not working ;(
>
><class-descriptor 
>       class="test.ojb.datamodel.User">
>       <extent-class class-ref="test.ojb.datamodel.impl.UserImpl"/>
></class-descriptor>
><class-descriptor 
>       class="test.ojb.datamodel.impl.UserImpl" 
>       table="USER" 
>       factory-class="test.ojb.datamodel.impl.FactoryImpl"
>       factory-method="createUser">
>       <field-descriptor 
>               name="id" 
>               column="ID" 
>               jdbc-type="INTEGER"
>               primarykey="true"
>               nullable="false"
>               autoincrement="true"
>               access="readonly"/>     
>       <field-descriptor 
>               name="groupId"
>               column="GROUP_ID"
>               jdbc-type="INTEGER"
>               access="anonymous"
>       />      
>       <reference-descriptor
>               name="group"
>               class-ref="test.ojb.datamodel.Group"
>               proxy="true"
>       >
>               <foreignkey field-ref="groupId"/>
>       </reference-descriptor> 
></class-descriptor>
>
><class-descriptor 
>       class="test.ojb.datamodel.Group">
>       <extent-class class-ref="test.ojb.datamodel.impl.GroupImpl"/>
></class-descriptor>
><class-descriptor 
>       class="test.ojb.datamodel.impl.GroupImpl" 
>       table="GROUP1" 
>       factory-class="test.ojb.datamodel.impl.FactoryImpl"
>       factory-method="createGroup">
>       <field-descriptor 
>               name="id" 
>               column="ID" 
>               jdbc-type="INTEGER"
>               primarykey="true"
>               nullable="false"
>               autoincrement="true"
>               access="readonly"/>     
>       <field-descriptor 
>               name="managerId"
>               column="MANAGER_ID"
>               jdbc-type="INTEGER"
>               access="anonymous"
>       />      
>       <reference-descriptor
>               name="manager"
>               class-ref="test.ojb.datamodel.User"
>               proxy="true"
>       >
>               <foreignkey field-ref="managerId"/>
>       </reference-descriptor> 
></class-descriptor>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>  
>


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


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

Reply via email to