Hi Martin,

Martin I. Levi wrote:

Hi!

I have an object with many 1:1 relations and I want to update one of
these relations just changing the FK in the main object, is this
possible?

If you materialize this object all 1:1 relations will be materialized too (except lazy materialization was used). If you change the FK the reference to the old object is still alive and on commit OJB will find the old object and replace the new FK with the old one. So I'm not sure that your test will pass.
Replace the referenced object by the new one.


How can I tell OJB to reload the embedded object (associated
to the relation)? Is this the best way to update a 1:1 relation?


To retrieve unmaterialized references (e.g. auto-retrieve="false") or to reassign you can use PB#retrieveReference(...).


Have a look at 'refresh' attribute
http://db.apache.org/ojb/docu/guides/repository.html#reference-descriptor

Or remove the main object from the cache, then OJB re-read the main object from the DB.

regards,
Armin


BTW: I am working with the ODMG api.



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



Reply via email to