Re: Very interesting case
Re: Very interesting case
- Subject: Re: Very interesting case
- From: Chuck Hill <email@hidden>
- Date: Mon, 21 Sep 2009 13:31:37 -0700
On Sep 21, 2009, at 1:17 PM, Don Lindsay wrote:
Hello;
I have a component that I am updating a table of answers based on
selections made by the user from a worepitition.
The code being executed is:
try {
String sEoQualifierText = "page=";
sEoQualifierText +=
Integer.toString((Integer)thePage().valueForKey("identifier"));
sEoQualifierText += " and question=";
sEoQualifierText +=
Integer.toString((Integer)theQuestion().valueForKey("identifier"));
sEoQualifierText += " and user=";
sEoQualifierText += Integer.toString((Integer)
((EOEnterpriseObject)theUser).valueForKey("identifier"));
EOQualifier oQual =
EOQualifier.qualifierWithQualifierFormat(sEoQualifierText,null);
What are you doing? And why? What is
thePage().valueForKey("identifier")? Home brew binding sync? Generic
Record based EOs with no Java classes?
Wonder's ERXQ will make your life so much easier to read and maintain.
EOFetchSpecification oFetch = new
EOFetchSpecification("UserAnswers",oQual,null);
NSArray aAnswer = oEO().objectsWithFetchSpecification(oFetch);
oEO().lock();
Nooooooooooooooooooooooo.
<runs away screaming>
Why lock like that? Why not just gouge your eyes out and hammer
pencils into your ears? It will be quicker and less painful and just
as effective.
Locking like that is useless and wrong and just won't work. Ever.
Use ERXEC or the MultiECLockManager. Your chances of doing it right
another other way approach null.
((UserAnswers
)aAnswer.objectAtIndex(0)).setTheAnswer((QuestionLookup)theAnswer());
//((EOEnterpriseObject)aAnswer.objectAtIndex(0)).willChange();
oEO().unlock();
//System.out.println("updates to be saved: " +
oEO().updatedObjects());
oEO().saveChanges();
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println("hissssss, didn't work");
}
if (theAnswer!=null) {
System.out.println("append to response firing "+
(String)theAnswer.valueForKey("desc"));
} else {
System.out.println("append to response firing but the answer is
null");
}
ThePage is an item from a listing of available pages repetition.
TheQuestion is an item from listing of questions repitition.
TheUser is the user who is currently working with the page.
The entity has 4 attributes (user, page, question, answer).
When I turn on EO Debugging I see that an update is made, but when I
check the database the answer is always null. I do not get any
errors in the logs. If I had an error I could start working it out.
Anyone have any ideas?
My money is on "incorrect EC locking" followed by "violating EOF
commandments". This is the classic symptom of doing either (or both!)
of those.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden