Hello,
I understand that if I want to "bring an object from a previous transaction
into the current transaction context", I have to call db.update(obj).
However, I have a fairly complex set of foreign keys, and all kinds other
objects that are read only (like dropdown list tables to which the main
record has a foreign key) are requiring that I call db.update() on them.
This becomes unwieldy very quickly. Is there a way that I can have objects
that are linked via foreign key, but are ignored in the current transaction
context. In other words, I want the db.commit() from the current
transaction to ignore them.
For example, I have something like the following:
USER
----
int userID; // Primary key
... // Other attributes
PROJECT
-------
int projectID; // Primary key
int userID; // Foreign key to USER
... // Other attributes
The USER object is loaded in a previous transaction. I want to commit
updates to the project attributes. However, I do NOT want to commit changes
to the USER object (In this case, USER cannot be edited, so it is
effectively read only). Due to the foreign key, it would seem I have to
call db.update(usr) within the transaction for updating PROJECT.
Here is an example of what I want to do in terms of updating an existing
project. It's also an issue when creating a new project. This is a trivial
example, as I have many layers of foreign keys, so the db.update() calls
would be numerous.
<PSEUDO-CODE SNIPPET>
db.begin(); // Begin transaction
db.update(usr); // I don't want to call this,
since the primary
// key is immutable
and the attributes are read-only.
// However, without
this, Castor throws an exception.
proj = db.load(Project, projPrimKey); // Load the project with the primary
key
proj.setUser(usr); // Set user for the project to
the current user
proj.setAttr1("foo"); // Set other project attributes
proj.setAttr2("bar");
db.commit(); // Commit the changes to
project
</PSEUDO-CODE SNIPPET>
Is there a way I can avoid calling db.update(usr)?
OR, is there a way I can call db.update(*), where all dependent objects
would have update called on them?
Is this a problem with my mappings file? I thought this might be affected
by the dependent or read-only attributes in the mapping files, but I haven't
had any luck experimenting with them so far. It seems that if I could
declare the project <-> user relationship independent, that Castor wouldn't
try to commit changes to the USER object, which would be ideal.
Thanks!
Matthew
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev