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 St...@zas.admin.ch on 2004/07/08 15:57:05 UTC

Réf. : Re: Mixing OJB objects with non-OJB objects




Thank you for the quick answer. I defined a custom RowReader and it works
almost exactly like I want to.

I would be fully happy if I could cache the object in the
PersistenceBroker's cache. Is there a way to get a reference to the cache
from the RowReader ?

Stefano




|---------+--------------------------->
|         |           Thomas Dudziak  |
|         |           <tomdz@first.fhg|
|         |           .de>            |
|         |                           |
|         |           08.07.2004 09:34|
|         |           Veuillez        |
|         |           répondre à "OJB |
|         |           Users List"     |
|         |                           |
|---------+--------------------------->
  >----------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                      |
  |        Pour :   OJB Users List <oj...@db.apache.org>                                                              |
  |        cc :                                                                                                          |
  |        Objet :  Re: Mixing OJB objects with non-OJB objects                                                          |
  >----------------------------------------------------------------------------------------------------------------------|




Stefano.Juri@zas.admin.ch wrote:

> Hello,
>
> I have two types of persistent objects in my application : objects that
are
> stored in a RDB and objects that are managed from an other application
(for
> instance, in my environment persons and adresses are managed in a legacy
> application developed in Natural/Adabas). The objects of the second type
> are considered as read-only, I don'need to store them back after the
> processing. The objects of both types are mixed in the business model,
the
> business layer of the application does not need to bother where the data
is
> stored.
>
> Example : I have a class Car with has an Owner. Car is stored in my RDB
and
> the table contains the identifier of the owner. Owner is stored in the
> external application. When OJB instantiates aCar it should also
instantiate
> it's Owner.
>
> I tried with the factory-class, but since the factory-method does not
> accept parameters, I don't know how to pass the identifier of the owner
and
> I need that information to call the external application's API. Is there
a
> way to get access to the db-row from the factory-method ? If no, is there
a
> smarter way to do the job ?

Dependiding on whether you want to map the Owner's identifier to a field
of Car, you can use initialization-method (class descriptor) which is
called after OJB has read the object from the database (if I'm not
mistaken), or you can use a custom row-reader implementation to fetch
the additional row from the db:

http://db.apache.org/ojb/docu/guides/advanced-technique.html#Using+Rowreader


Tom

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





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


Re: Mixing OJB objects with non-OJB objects

Posted by Thomas Dudziak <to...@first.fhg.de>.
Stefano.Juri@zas.admin.ch wrote:

>Thank you for the quick answer. I defined a custom RowReader and it works
>almost exactly like I want to.
>
>I would be fully happy if I could cache the object in the
>PersistenceBroker's cache. Is there a way to get a reference to the cache
>from the RowReader ?
>  
>
You can get the currently used cache from a PersistenceBroker via the 
serviceObjectCache() method.

Tom


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