On Jun 28, 2006, at 9:09 PM, Owen McKerrow wrote:

EOEditingContext ec = new EOEditingContext();
AuditLog newLog = (AuditLog) EOUtilities.createAndInsertInstance(ec,"AuditLog");
newLog.setPerson((Person)EOUtilities.localInstanceOfObject(ec,((Session)session()).currentPerson()));
newLog.setEntityName("TestEntity");
newLog.setIpAddress(((Session)session()).getIPAddress(context().request()));
newLog.setAttributeName("TestAttribute");
newLog.setNewValue("NewValue");
newLog.setOldValue("OldValue");
ec.saveChanges();

Others have suggested some solutions.  To avoid other potential problems, lock your new editing context prior to using it and unlock it afterward, and invoke ec.saveChanges() in a try-catch block.  Maybe you just omitted these statements to simplify your example.

EOEditingContext ec = new EOEditingContext();
ec.lock();
try {
    AuditLog newLog = (AuditLog) EOUtilities.createAndInsertInstance(ec,"AuditLog");
    ...
    try {
        ec.saveChanges();
    }
    catch (RuntimeException anException) {
        // Deal with exception
    }
}
finally {
ec.unlock();
}

Aloha,
Art

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to