You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Sergey Manukyan <sm...@gmx.net> on 2004/01/21 16:55:57 UTC

problem using anonymous fields...

Folks,

 

Why
java.org.apache.ojb.broker.accesslayer.JdbcAccessImpl.materializeObject(Clas
sDescriptor cld, Identity oid) doesn't resolve references? 

 

Here is a javadoc excerpt:

 

    /**

     * performs a primary key lookup operation against RDBMS and
materializes

     * an object from the resulting row. Only skalar attributes are filled
from

     * the row, references are not resolved.

     * @param oid contains the primary key info.

     * @param cld ClassDescriptor providing mapping information.

     * @return the materialized object, null if no matching row was found or
if

     * any error occured.

     */

    public Object materializeObject(ClassDescriptor cld, Identity oid)

        throws PersistenceBrokerException

    {

 

It created problems when I am using anonymous fields.

 

      retVal = broker.getObjectByQuery(

new QueryByIdentity(example));

 

      returns null, but the record exists!

 

Is there any workaround to keep using anonymous keys and be able to find
object by example?

 

Here is a class I am testing :

 

<class-descriptor class="beans.Tracking" table="SDRTII">

      <field-descriptor name="diverseSuppNum" column="DIVSUP#"
jdbc-type="DECIMAL" primarykey="true" access="anonymous" />

      <field-descriptor name="amount" column="AMOUNT" jdbc-type="DECIMAL" />

 

      <reference-descriptor name="diverseSupplier"
class-ref="beans.DiverseSupplier">

            <foreignkey field-ref="diverseSuppNum" />

      </reference-descriptor>

</class-descriptor>

 

 

Thank you,

-Sergey

 

 

 

 


Re: problem using anonymous fields...

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Sergey,

in your class-descriptor you define
...
 > <field-descriptor name="diverseSuppNum" column="DIVSUP#"
 > jdbc-type="DECIMAL" primarykey="true" access="anonymous" />
 >
 > <field-descriptor name="amount" column="AMOUNT" jdbc-type="DECIMAL" />
 >
...

You declare 'diverseSuppNum' as anonymous. This means that 
'diverseSuppNum' is not visible on Object/User level - you hide it.
Further is 'diverseSuppNum' PK field.

 >       retVal = broker.getObjectByQuery(
 >
 > new QueryByIdentity(example));

If your example object looks like Tracing --> DiverseSupplier
Then OJB try to build a Identity object based on the PK, but in your 
case PK was never populated, because it's anonymous. Could this be the 
reason for your hassle?

regards,
Armin

Sergey Manukyan wrote:

> Folks,
> 
>  
> 
> Why
> java.org.apache.ojb.broker.accesslayer.JdbcAccessImpl.materializeObject(Clas
> sDescriptor cld, Identity oid) doesn't resolve references? 
> 
>  
> 
> Here is a javadoc excerpt:
> 
>  
> 
>     /**
> 
>      * performs a primary key lookup operation against RDBMS and
> materializes
> 
>      * an object from the resulting row. Only skalar attributes are filled
> from
> 
>      * the row, references are not resolved.
> 
>      * @param oid contains the primary key info.
> 
>      * @param cld ClassDescriptor providing mapping information.
> 
>      * @return the materialized object, null if no matching row was found or
> if
> 
>      * any error occured.
> 
>      */
> 
>     public Object materializeObject(ClassDescriptor cld, Identity oid)
> 
>         throws PersistenceBrokerException
> 
>     {
> 
>  
> 
> It created problems when I am using anonymous fields.
> 
>  
> 
>       retVal = broker.getObjectByQuery(
> 
> new QueryByIdentity(example));
> 
>  
> 
>       returns null, but the record exists!
> 
>  
> 
> Is there any workaround to keep using anonymous keys and be able to find
> object by example?
> 
>  
> 
> Here is a class I am testing :
> 
>  
> 
> <class-descriptor class="beans.Tracking" table="SDRTII">
> 
>       <field-descriptor name="diverseSuppNum" column="DIVSUP#"
> jdbc-type="DECIMAL" primarykey="true" access="anonymous" />
> 
>       <field-descriptor name="amount" column="AMOUNT" jdbc-type="DECIMAL" />
> 
>  
> 
>       <reference-descriptor name="diverseSupplier"
> class-ref="beans.DiverseSupplier">
> 
>             <foreignkey field-ref="diverseSuppNum" />
> 
>       </reference-descriptor>
> 
> </class-descriptor>
> 
>  
> 
>  
> 
> Thank you,
> 
> -Sergey
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org