db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henning P. Schmiedehausen" <...@intermeta.de>
Subject Re: save an object tree / bug concerning the MODIFIED-flag
Date Tue, 14 Sep 2004 23:36:58 GMT
"Henning P. Schmiedehausen" <hps@intermeta.de> writes:

>>I would appreciate if Torque saved an object tree for me -
>>e.g. I have a Book with two Authors and want to call

>> book.addAuthor(a1);
>> book.addAuthor(a2);
>> BookPeer.doSave(book);    // should insert or update the book and both

>Well, Torque does not work this way. The foreign key getters are just shortcuts

>Object.getForeigns() is equivalent to

>Criteria crit = new Criteria();
>crit.add(ForeignPeer.OBJECT_ID, Object.OBJECT_ID);
>List foreigns = ForeignPeer.doSelect(crit);

>There are no setters for this (or add<xxx> methods. The objects do not
>cache intermediate collections of objects.


>>So, finally my 2 questions:
>>- Did I miss a Torque feature that saves an object tree for me?

>No. There is no such thing in current Torque (at least 3.1). If you
>want to save an object tree, it might be possible to write such a
>bugger but you would end up with either having to retrieve existing
>objects for your foreign keys (expensive) or some sort of caching (as
>Hibernate does).

Ok. I put my foot in my mouth a little (I shouldn't post past 1am):
There actually _is_ such a thing. Sorry.

There are two Object flavours. The classes that are created with

torque.objectIsCaching = false  

in project.properties behave just like I wrote. If you put

torque.objectIsCaching = true

in your project.properties before generating your peers/objects then
you will have add<ForeignKeyObject>s methods in your object classes.

I do remember now that I've tried these once. As you are a german,
this is verbatim from my application project.properties file after
trying this out:

--- cut ---
# Unsere Objekte duerfen nicht cachen, sonst geschehen schlimme
# Dinge!
torque.objectIsCaching = false
--- cut ---


P.S.: Rough translation is "Our object must not cache or bad things
will happen!" I my case, the bad things were that my application ate
my database. There were some issues with the id generation of the
connected objects. I can't recall the exact problems anymore and it is
quite possible that they are gone from the 3.1.1 (and 3.2) tree. YMMV.

P.P.S.: I'm pretty sure that this simply needs more debugging. Patches

Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

"Fighting for one's political stand is an honorable action, but re-
 fusing to acknowledge that there might be weaknesses in one's
 position - in order to identify them so that they can be remedied -
 is a large enough problem with the Open Source movement that it
 deserves to be on this list of the top five problems."
                       -- Michelle Levesque, "Fundamental Issues with
                                    Open Source Software Development"

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

View raw message