Sorry for the cross-post. I posted this to the EOF list a few days ago but
it seems that the WOF list is where all the action is these days.
I believe this is a bug in the current release of WO4/EOF. I'd be most
grateful if anyone can suggest a workaround. The problem appears to centre
around a project having multiple eomodels which connect to different
databases, and objects in those eomodels having relationships across models
to each other.
And please don't let the company standard email disclaimer at the end put
you off replying!
Thanks -- original message follows:
-------------------------------------------------------------------------
Hello
Well I'm opening myself up to a fresh torrent of spam in the hope that
someone here can help me. I'd like to know if I'm doing something wrong here
or am hitting a (dare I suggest it) bug in EOF3.0. The smart money's on me
doing something wrong. I'd be grateful at least if anyone else who's
encountered anything like this could give me some clues, a 'me too',
workaround, anything...
Garrick McFarlane, OO Type
Linklaters and Paines
London, England
Tel: +44 171 456 5765
----
Environment:
EOF3.0; Java; WOF4.0; NT4SP3; Sybase
Possible factors:
multi-eomodel project/app, including cross-model,
cross-database relationships.
Error encountered:
"recordToManySnapshots:: cannot record objects in a context when no
transaction is in progress"
Scenario:
I'm instantiating a couple of eocustomobject subclasses, inserting
them into an editingcontext, relating them to some preexisting fetched
eocustomobject subclasses in another model/database, and then saving the
editing context. All objects (in all models) are in the same editing
context. EOF is successfully preparing the objects, fetching primary keys,
generating the correct 'INSERT INTO' SQL, submitting it to Sybase, but then
just when everything appears to have completed, the whole lot gets rolled
back with the EOF error message above.
If I remove the 'addObjectToBothSidesOfRelationship' calls which relate the
new instances to objects in other models/databases, the
editingcontext.save() succeeds. But, of course, I need my objects to be
related across the models...
Detail (1) Runtime output:
Feb 18 11:40:47 intrabill2[409] === Begin Internal Transaction
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> executing
SQL: execute eo_pk_for_table 'request_entry']
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> SQL
execution succeeded]
Feb 18 11:40:47 intrabill2[409] *** <SybaseChannel: 0xad6420> 1 rows
processed
Feb 18 11:40:47 intrabill2[409] === Commit Internal Transaction
Feb 18 11:40:47 intrabill2[409] === Begin Internal Transaction
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> executing
SQL: execute eo_pk_for_table 'request']
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> SQL
execution succeeded]
Feb 18 11:40:47 intrabill2[409] *** <SybaseChannel: 0xad6420> 1 rows
processed
Feb 18 11:40:47 intrabill2[409] === Commit Internal Transaction
Feb 18 11:40:47 intrabill2[409] === Begin Internal Transaction
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> executing
SQL: BEGIN TRANSACTION]
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> SQL
execution succeeded]
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> executing
SQL: INSERT INTO request (requestor_id, matter_id, request_id,
request_prose, requested_on) VALUES ('JGP', '001207579', 8, 'request
details', '19990218 11:40:46:896')]
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> SQL
execution succeeded]
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> executing
SQL: INSERT INTO request_entry (request_id, prose, raised_by_id, raised_on,
request_entry_id) VALUES (8, 'Request created by proxy', 'DWC', '19990218
11:40:47:146', 7)]
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> SQL
execution succeeded]
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> executing
SQL: ROLLBACK TRANSACTION]
Feb 18 11:40:47 intrabill2[409] *** [<SybaseChannel: 0xad6420> SQL
execution succeeded]
Feb 18 11:40:47 intrabill2[409] === Rollback Internal Transaction
Feb 18 11:40:47 intrabill2[409] <WOApplication 'intrabill2'>:
NSInvalidArgumentException exception occurred while handling request:
Exception occured while evaluating 'webCreateRequest', on
target:<JAWSNewRequest 0xb0a380>:
recordToManySnapshots:: cannot record objects in a context when no
transaction is in progress
Detail (2) Code samples:
public JAWSRequestHistory webCreateRequest()
{
LPRequest lNewRequest; // The new Request to create and insert
(master object)
LPRequestEntry lRequestEntry; // The new RequestEntry (detail
object)
// Create and insert master object
lNewRequest = new LPRequest (webMatter, webRequestor, webProse);
this.session().defaultEditingContext().insertObject (lNewRequest);
// Create and insert detail object
lRequestEntry = new LPRequestEntry ("Request created by
proxy",
((Session)
this.session()).currentLogin(),
lNewRequest);
this.session().defaultEditingContext().insertObject (lRequestEntry);
// Save to database
// [** This fails and rolls back **]
this.session().defaultEditingContext().saveChanges();
return JAWSRequestHistory.historyForRequest (lNewRequest, this);
}
In the EOCustomObject subclasses, these are the constructors called above:
public LPRequest (LPMatter aMatter,
LPPerson aRequestor,
String aProse)
{
// Invoke default constructor
this (aMatter.editingContext(),
EOClassDescription.classDescriptionForEntityName ("LPRequest"), null);
// Set values and manipulate relationships
this.setRequestedOn (new NSGregorianDate());
this.setRequestProse (aProse);
this.addObjectToBothSidesOfRelationshipWithKey (aRequestor,
"requestor");
this.addObjectToBothSidesOfRelationshipWithKey (aMatter, "matter");
}
public LPRequestEntry (String aProse,
LPPerson aRaiser,
LPRequest aRequest)
{
// Invoke default constructor
this (aRaiser.editingContext(),
EOClassDescription.classDescriptionForEntityName ("LPRequestEntry"), null);
// Set values and manipulate relationships
this.setRaisedOn (new NSGregorianDate());
this.setProse (aProse);
this.addObjectToBothSidesOfRelationshipWithKey (aRaiser,
"raisedBy");
this.addObjectToBothSidesOfRelationshipWithKey (aRequest,
"request");
}
____________________________________________________________
This message is confidential. It may also be privileged or
otherwise protected by work product immunity or other legal
rules. If you have received it by mistake please let us know
by reply and then delete it from your system; you should not
copy the message or disclose its contents to anyone.
____________________________________________________________