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 Vincent Frison <tu...@ohmforce.com> on 2003/05/05 17:02:21 UTC

Quick updates for 1:1 relations

Hi,

I'd like to know if it would be possible to update a reference just by
updating the FK field without updating the referenced object.

Example: the class Software references the class Editor with a 1:1
relation. So the class Software contains a (Editor) editor field and an
(int) editorId (which is the FK).

If I have to change the editor of a particular software, I have to:

1) Retrieve the correct Software object.
1) Instanciate a new Editor object (or retrieving a existing one from a
broker request).
3) Call the setEditor() method of the Software object.
4) Store the Software object. 

Note that if I just call the setEditorId() of the Software object, the
reference is not well updated (until the next application restart),
although the editorId field is well updated in the DB. So I have to do
the entire process mentioned previously if I want my referenced objects
to be well updated.

That's a good way, but in some cases it could be considered as a heavy
process because I have *already* the correct Editor PK (in fact this is
a usual case in my app). In these cases, directly updating the FK of the
Software object (without instancing or loading an entire Editor object)
would be really appreciated isn't it? Maybe this method shouldn't be
considered as very elegant one from a persistence layer point of view
(which tends to manage the PK and FK in a transparent way), but what
about the performances?

-- 
------------------------------------------------------------
Vincent Frison                     |               Ohm Force
System Administrator               |  Digital Audio Software
mailto:vincent.frison@ohmforce.com | http://www.ohmforce.com
------------------------------------------------------------