I added the (int) clientRelationshipId to NewClientGroup and removed the
access="anonymous" from the field-descriptor.  I am still getting the
same error.

-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 24, 2005 9:04 AM
To: OJB Users List
Subject: Re: Problem retrieving collection.


Hi Wes,

comments see below

Lemke, Wesley wrote:
> No problem.  I think this is everything needed:
> 
> package model;
> // All persistent Object extend this class, the unique object ID // is

> from this class along with some other fields public class AdmObject 
> implements Serializable{
>       
>       private int objectId = -1;
>       // A few other fields, removed for simplification
> }
> 
> package model.client;
> // Abstract class that NewClientGroup and Subgroup extend.
> // Both NewClientGroup and Subgroup are stored in the
> // client_group table.
> public abstract class GenericGroup extends AdmObject {
> 
>       private String name;
>       // A few other fields, removed for simplification
>       private String ojbConcreteClass;
> }
>       
> package model.client;
> // Contains Collection of NewClientGroups.
> // Persisted in client.
> public class ClientRelationship extends AdmObject {
> 
>       private String nameOfApproverOfNoContract;
>       private List clientGroups = new ArrayList();***
> }
> 
> package model.client;
> // One of two classes that extend GenericGroup.
> // Contains collection of Subgroups and reference
> // to ClientRelationship
> // Persisted in client_group.
> public class NewClientGroup extends GenericGroup {
> 
>       // A few other fields, removed for simplification
>       private List subgroups = new ArrayList();***
>       private ClientRelationship clientRelationship;
> }
> 
> ***The problem occurs when retrieving the clientGroups collection from

> ClientRelationship.  I am having the same problem when retrieving the 
> subgroups collection from NewClientGroup, but I'll leave that part out

> to simplify the problem.
> 
> Here are the class descriptors:
> 
> <class-descriptor
>       class="model.AdmObject">
>       <extent-class class-ref="model.client.ClientRelationship" />
>       <extent-class class-ref="model.client.GenericGroup" /> 
> </class-descriptor>
> 
> <class-descriptor
>       class="model.client.GenericGroup">
>       <extent-class class-ref="model.client.NewClientGroup" /> 
> </class-descriptor>
>
> <class-descriptor
>       class="model.client.ClientRelationship"
>       table="client">
>     <field-descriptor
>         name="objectId"
>         column="client_id"
>         jdbc-type="INTEGER"
>         primarykey="true"
>         autoincrement="true"
>         access="readonly"
>         />
>     <field-descriptor
>       name="nameOfApproverOfNoContract"
>       column="agr_approver"
>       jdbc-type="VARCHAR"
>       />      
>       <collection-descriptor
>               name="clientGroups"
>               element-class-ref="model.client.NewClientGroup"
>               auto-delete="true"
>               auto-update="true"
>       >
>               <inverse-foreignkey field-ref="clientRelationshipId" />
>       </collection-descriptor>    
> </class-descriptor>
> 
> <class-descriptor
>       class="model.client.NewClientGroup"
>       table="client_group">
>       <field-descriptor
>               name="objectId"
>               column="group_id"
>               jdbc-type="INTEGER"
>               primarykey="true"
>               autoincrement="true"
>               access="readonly"
>       />
>       <field-descriptor
>               name="clientRelationshipId"
>               column="client_id"
>               jdbc-type="INTEGER"
>               access="anonymous"
>       />      

Field "clientRelationshipId" was used by a 1:n relationship, so using an

anonymous key can be problematic. See
http://db.apache.org/ojb/docu/guides/advanced-technique.html#How+do+

Try to make this field a normal field in NewClientGroup. If you using 
PersistentFieldDirectAccessImplNew as PersistentField implementation in 
OJB.properties file (default setting), no get/setter needed.

The error message is strange I can't find a typo or incorrect mapping.

Armin


>       <field-descriptor
>               name="name"
>               column="NAME"
>               jdbc-type="VARCHAR"
>       />
>       <field-descriptor
>               name="ojbConcreteClass"
>               column="CLASS_NAME"
>               jdbc-type="VARCHAR"
>       />
>       <reference-descriptor name="clientRelationship" 
> class-ref="model.client.ClientRelationship">
>               <foreignkey field-ref="clientRelationshipId"/>
>       </reference-descriptor>                                         
> </class-descriptor>
> 
> The objects persist fine.  Here is the data in the tables after a 
> store:
> 
> mysql> select * from client;
> +-----------+--------------+--------------------+
> | client_id | agr_approver | last_modified_user |
> +-----------+--------------+--------------------+
> |         1 | Zeus         | NULL               |
> +-----------+--------------+--------------------+
> 1 row in set (0.00 sec)
> 
> mysql> select group_id, client_id, name, parent_id, class_name from
> client_group;
> +----------+-----------+---------------------+-----------+------------
> +----------+-----------+---------------------+-----------+--
> ---------------+
> | group_id | client_id | name                | parent_id | class_name
> |
> +----------+-----------+---------------------+-----------+------------
> +----------+-----------+---------------------+-----------+--
> ---------------+
> |        1 |         1 | First Client Group  |      NULL |
> model.client.NewClientGroup |
> |        2 |         1 | Second Client Group |      NULL |
> model.client.NewClientGroup |
> +----------+-----------+---------------------+-----------+------------
> +----------+-----------+---------------------+-----------+--
> ---------------+
> 2 rows in set (0.00 sec)
> 
> When I try to retrieve an object, this is the error I get:
> 
> Error 500: Server caught unhandled exception from servlet
> [servlets.InheritanceServlet]:
> org.apache.ojb.broker.OJBRuntimeException: Incorrect or not found 
> field reference name 'clientRelationshipId' in descriptor 
> [EMAIL PROTECTED]
> et
>
rieve=true,cascade_store=object,cascade_delete=object,is_lazy=false,clas
> s_of_Items=class model.client.NewClientGroup] for class-descriptor
> 'model.client.ClientRelationship'
> 
> Wallace Joseph Gelhar wrote:
> 
> 
>>OJB currently only joins on the related object primary key (which it
> 
> already knows from the mapping), so what is        >needed is the
> foreign key field in NewClientGroup that relates to 
> ClientRelationship.
> 
>>Remember that in Reference or Collection Descriptors it is always
> 
> looking for the foreign key.
> 
>>Hope this helps.
> 
> 
> If that is the case, then why is OJB looking in 
> model.client.ClientRelationship for clientRelationshipId?  It should 
> be "joining the objects" on ClientRelationship.objectId and 
> NewClientGroup.clientRelationshipId.
> 
> Thanks for the effort so far, I do appreciate it.
> 
> Here is the entire stack trace if it helps:
> 
> [3/24/05 8:24:49:666 CST] 1048d672 SystemOut     O
> [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG:

> SQL:SELECT A0.agr_approver,A0.client_id FROM client A0 [3/24/05 
> 8:24:49:696 CST] 1048d672 ConnectionFac I J2CA0122I: Resource 
> reference jdbc/ao79 could not be located, so default values of the 
> following are used: [Resource-ref settings]
> 
>       res-auth:                 1 (APPLICATION)
>       res-isolation-level:      0 (TRANSACTION_NONE)
>       res-sharing-scope:        true (SHAREABLE)
>       res-resolution-control:   999 (undefined)
> [Other attributes]
> 
> isCMP1_x:                 false (not CMP1.x)
> isJMS:                 false (not JMS)
> 
> [3/24/05 8:24:49:916 CST] 1048d672 SystemOut     O
> [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG:

> SQL:SELECT A0.CLASS_NAME,A0.group_id,A0.NAME,A0.client_id FROM 
> client_group A0 WHERE ( A0.client_id = ?) AND  (A0.CLASS_NAME = ?)
> [3/24/05 8:24:49:966 CST] 1048d672 SystemErr     R
> org.apache.ojb.broker.OJBRuntimeException: Incorrect or not found 
> field reference name 'clientRelationshipId' in descriptor 
> [EMAIL PROTECTED]
> et
>
rieve=true,cascade_store=object,cascade_delete=object,is_lazy=false,clas
> s_of_Items=class model.client.NewClientGroup] for class-descriptor
> 'model.client.ClientRelationship'
>       at
>
org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyFi
> eldDescriptors(Unknown Source)
>       at
>
org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyVa
> lues(Unknown Source)
>       at
>
org.apache.ojb.broker.accesslayer.CollectionPrefetcher.associateBatched(
> Unknown Source)
>       at
>
org.apache.ojb.broker.accesslayer.BasePrefetcher.prefetchRelationship(Un
> known Source)
>       at
>
org.apache.ojb.broker.core.QueryReferenceBroker.performRetrievalTasks(Un
> known Source)
>       at
>
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unk
> nown Source)
>       at
>
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unk
> nown Source)
>       at
>
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unk
> nown Source)
>       at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Un
> known Source)
>       at
>
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQu
> ery(Unknown Source)
>       at
>
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQu
> ery(Unknown Source)
>       at
> servlets.InheritanceServlet.printGroups(InheritanceServlet.java:123)
>       at
> servlets.InheritanceServlet.doPost(InheritanceServlet.java:75)
>       at servlets.InheritanceServlet.doGet(InheritanceServlet.java:44)
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictSe
> rvletInstance.java:110)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLi
> fecycleServlet.java:174)
>       at
>
com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycle
> Servlet.java:313)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLif
> ecycleServlet.java:116)
>       at
>
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.
> java:283)
>       at
>
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(Vali
> dServletReferenceState.java:42)
>       at
>
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(Servle
> tInstanceReference.java:40)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispa
> tch(WebAppRequestDispatcher.java:948)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRe
> questDispatcher.java:530)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppReq
> uestDispatcher.java:176)
>       at
>
com.ibm.ws.webcontainer.servlet.InvokerServlet.service(InvokerServlet.ja
> va:255)
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictSe
> rvletInstance.java:110)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLi
> fecycleServlet.java:174)
>       at
>
com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycle
> Servlet.java:313)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLif
> ecycleServlet.java:116)
>       at
>
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.
> java:283)
>       at
>
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(Vali
> dServletReferenceState.java:42)
>       at
>
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(Servle
> tInstanceReference.java:40)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispa
> tch(WebAppRequestDispatcher.java:948)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRe
> questDispatcher.java:530)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppReq
> uestDispatcher.java:176)
>       at
>
com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:7
> 9)
>       at
>
com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInv
> oker.java:201)
>       at
>
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocati
> on(CachedInvocation.java:71)
>       at
>
com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(Servle
> tRequestProcessor.java:182)
>       at
>
com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSELis
> tener.java:334)
>       at
>
com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection
> .java:56)
>       at
>
com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:
> 610)
>       at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
>       at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
> [3/24/05 8:24:53:702 CST] 1048d672 WebGroup      E SRVE0026E: [Servlet
> Error]-[servlets.InheritanceServlet]:
> org.apache.ojb.broker.PersistenceBrokerException:
> org.apache.ojb.broker.OJBRuntimeException: Incorrect or not found
field
> reference name 'clientRelationshipId' in descriptor
>
[EMAIL PROTECTED]
>
rieve=true,cascade_store=object,cascade_delete=object,is_lazy=false,clas
> s_of_Items=class model.client.NewClientGroup] for class-descriptor
> 'model.client.ClientRelationship'
>       at
>
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unk
> nown Source)
>       at
>
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unk
> nown Source)
>       at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Un
> known Source)
>       at
>
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQu
> ery(Unknown Source)
>       at
>
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQu
> ery(Unknown Source)
>       at
> servlets.InheritanceServlet.printGroups(InheritanceServlet.java:123)
>       at
> servlets.InheritanceServlet.doPost(InheritanceServlet.java:75)
>       at servlets.InheritanceServlet.doGet(InheritanceServlet.java:44)
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictSe
> rvletInstance.java:110)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLi
> fecycleServlet.java:174)
>       at
>
com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycle
> Servlet.java:313)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLif
> ecycleServlet.java:116)
>       at
>
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.
> java:283)
>       at
>
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(Vali
> dServletReferenceState.java:42)
>       at
>
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(Servle
> tInstanceReference.java:40)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispa
> tch(WebAppRequestDispatcher.java:948)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRe
> questDispatcher.java:530)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppReq
> uestDispatcher.java:176)
>       at
>
com.ibm.ws.webcontainer.servlet.InvokerServlet.service(InvokerServlet.ja
> va:255)
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictSe
> rvletInstance.java:110)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLi
> fecycleServlet.java:174)
>       at
>
com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycle
> Servlet.java:313)
>       at
>
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLif
> ecycleServlet.java:116)
>       at
>
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.
> java:283)
>       at
>
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(Vali
> dServletReferenceState.java:42)
>       at
>
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(Servle
> tInstanceReference.java:40)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispa
> tch(WebAppRequestDispatcher.java:948)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRe
> questDispatcher.java:530)
>       at
>
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppReq
> uestDispatcher.java:176)
>       at
>
com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:7
> 9)
>       at
>
com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInv
> oker.java:201)
>       at
>
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocati
> on(CachedInvocation.java:71)
>       at
>
com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(Servle
> tRequestProcessor.java:182)
>       at
>
com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSELis
> tener.java:334)
>       at
>
com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection
> .java:56)
>       at
>
com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:
> 610)
>       at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
>       at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
> Caused by: org.apache.ojb.broker.OJBRuntimeException: Incorrect or not
> found field reference name 'clientRelationshipId' in descriptor
>
[EMAIL PROTECTED]
>
rieve=true,cascade_store=object,cascade_delete=object,is_lazy=false,clas
> s_of_Items=class model.client.NewClientGroup] for class-descriptor
> 'model.client.ClientRelationship'
>       at
>
org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyFi
> eldDescriptors(Unknown Source)
>       at
>
org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyVa
> lues(Unknown Source)
>       at
>
org.apache.ojb.broker.accesslayer.CollectionPrefetcher.associateBatched(
> Unknown Source)
>       at
>
org.apache.ojb.broker.accesslayer.BasePrefetcher.prefetchRelationship(Un
> known Source)
>       at
>
org.apache.ojb.broker.core.QueryReferenceBroker.performRetrievalTasks(Un
> known Source)
>       at
>
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unk
> nown Source)
>       ... 41 more
> 
> [3/24/05 8:24:54:313 CST] 1048d672 OSEListenerDi E PLGN0021E: Servlet 
> Request Processor Exception: Virtual Host/WebGroup Not Found : The web

> group /favicon.ico has not been defined
> 
> -----Original Message-----
> From: Armin Waibel [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 24, 2005 8:12 AM
> To: OJB Users List
> Subject: Re: Problem retrieving collection.
> 
> 
> Hi Wes,
> 
>  > Is my assumption wrong?  In this case:
>  >
>  > <reference-descriptor name="clientRelationship"
>  > class-ref="model.client.ClientRelationship">
>  >            <foreignkey field-ref="objectId"/>
>  > </reference-descriptor>
>  >
>  > Isn't objectId supposed to be the primary key field of
>  > model.client.ClientRelationship?
> 
> sorry I'm a little confused after all the posts to this thread. Could
> you please post the class hierarchy (with all (important) fields of
the 
> classes, no get/setter) and the actual mapping of the classes again.
> 
> regards,
> Armin
> 
> ---------------------------------------------------------------------
> 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