"Bruce Snyder" <[EMAIL PROTECTED]> wrote:

> This one time, at band camp, Steffen Fiedler said:
> 
> SF>Hi,
> SF>
> SF>I have an application that works with objects, that are linked in many 
> SF>ways among each other.
> SF>What is the best  way to save them?
> SF>I try to to it by long transactions, because the Objects are used while 
> SF>the whole application
> SF>and and i don't want to hold one transaction all the time to hold them 
> SF>persistent.
> SF>Its a multi-user web-application and i can't be sure, that the conection 
> SF>will be closed correctly.
> SF>So i just open a connection, when some objects have to be 
> SF>read/saved/updated and want to
> SF>save them by long transactions. When i do this:
> SF>
> SF>db.setAutoStore(false);
> SF>db.begin();
> SF>db.update(myObject);
> SF>db.commit();
> SF>
> SF>i get the error:
> SF>
> SF>Commit failed: org.exolab.castor.jdo.TransactionAbortedException: Nested 
> SF>error:
> SF>org.exolab.castor.jdo.PersistenceException: Object, 
> SF>com.sourcepark.ticketsystem.Ticket@305236,
> SF>links to another object, com.sourcepark.ticketsystem.Priority@6a0105 
> SF>that is not
> SF>loaded/updated/created in this transaction
> SF>
> SF>If i set db.setAutoStore(true) i get the error:
> SF>
> SF>Error while saving object: 
> SF>org.exolab.castor.jdo.DuplicateIdentityException: update object
> SF>which is already in the transaction
> SF>
> SF>because i use some objects in many ways, i.e. the object 'state' can be 
> SF>a pre-state and a
> SF>successor-state for another object and there are many other relations 
> SF>like this. I've tried
> SF>to set the affected objects to access="read-only" in mapping.xml but 
> SF>without success.
> SF>
> SF>In the JDO-FAQ is written, that castor only supports bi-directional 
> SF>relationships, does
> SF>that mean, if object1 contains a reference to object2, object2 should 
> SF>contain a vector
> SF>of object1's?
> SF>
> SF>I expanded my mapping.xml, but now castor works very slowly, when i load 
> SF>a single
> SF>user, the whole datamodel is loaded from DB cause all objects are linked 
> SF>among each other.
> SF>Is it usefull to use castor for a web-application with complex 
> SF>datamodel? Whats about
> SF>performance when there are many users and large databases. Could 
> SF>lazy-loading solve this
> SF>problem?
> SF>
> SF>I've appended the whole mapping.xml for getting an impression about the 
> SF>object-structute.
> SF>My main question is, if it's advisable to use castor for a multi-user 
> SF>web-application with
> SF>such a  datamodel and if yes, what is the most performance-friendly 
> SF>approach to save and
> SF>load the objects.
> 
> Steffen,
> 
> I've found that Castor has it's limits with regards to very, very complex
> object models. Much of my experience with this has been learned at my
> day job where I work on a GIS application using highly complex data
> in a highly complex object model (polygons, etc). BTW, I would NOT
> consider your object model to be highly complex. Castor should handle
> this just fine.
> 
> I've also found that Castor does not enforce the bi-directional relations
> at all times (as is stated in the JDO FAQ). This being said, I've used
> Castor in the past with an object model similar to yours by not mapping
> things bi-directionally. (This took some time to figure out because there
> are situations where Castor wants a bi-directional mapping and other
> situations where it doesn't matter (there are threads on the mailing
> list discussing this, unfortunately I don't know the ins and outs of
> this off the top of my head).) The situation to which I'm referring
> was a mutli-user web app using long transactions. In this setting,
> Castor performed just fine. 
> 
> Unfortunately I have no easy answer for this situation. However,
> if you take the time to experiment with the removal of many of the
> bi-directional references in your object model, I believe you'll start
> to get the results you want.

Ok thanks, i'll try a bit around.
How can i avoid the Exception:
"org.exolab.castor.jdo.DuplicateIdentityException: update object
which is already in the transaction"
while using long transactions? The affected objects don't have
to be changed in this situation and read-only="true" doesn't
change anything.
The only way i found is to change objects by loading them and
all there linked objects in short transactions.
But i think, its not the best way...

Steffen

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to