RE: Strange EOF exception
RE: Strange EOF exception
- Subject: RE: Strange EOF exception
- From: "Pierre Bernard" <email@hidden>
- Date: Fri, 23 Jan 2004 14:48:16 +0100
- Thread-topic: Strange EOF exception
Hi!
I have filed this as bug #3538032 on radar.
The submitted sample code is as follows:
public class Application extends WOApplication
{
public Application()
throws Exception
{
EOEditingContext editingContext = new EOEditingContext(); // workaround : use test.EditingContext
PbTest object = null;
editingContext.lock();
// Fetch one of the test objects
try
{
NSArray objects = EOUtilities.objectsForEntityNamed(editingContext, "Pbtest");
if (objects.count() > 0)
{
object = (PbTest) objects.lastObject();
}
else
{
throw new Exception("Please insert some new rows into the test table");
}
}
finally
{
editingContext.unlock();
}
editingContext.lock();
// Mark it as changed and attempt saving
try
{
object.willChange();
editingContext.saveChanges();
}
catch (NSValidation.ValidationException ve)
{
NSLog.out.appendln("Validation failed as expected");
}
finally
{
editingContext.unlock();
}
editingContext.lock();
// Attempt top delete the modified object.
// The save operation will go throught to the database and throw afterwards
try
{
editingContext.deleteObject(object);
editingContext.saveChanges();
}
catch (Exception e)
{
NSLog.err.appendln("Saving changes threw an exception");
NSLog.err.appendln(e);
System.exit(1);
}
finally
{
editingContext.unlock();
}
System.exit(0);
}
public static void main(String argv[])
{
WOApplication.main(argv, Application.class);
}
}
public class PbTest extends EOGenericRecord
{
public PbTest()
{
super();
}
public void validateForSave()
throws NSValidation.ValidationException
{
super.validateForSave();
throw new NSValidation.ValidationException("Will always throw");
}
}
Pierre.
**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.