Re: EO not getting marked as needing to be updated
Re: EO not getting marked as needing to be updated
- Subject: Re: EO not getting marked as needing to be updated
- From: Chuck Hill <email@hidden>
- Date: Wed, 16 Jun 2004 22:55:04 -0700
Modifying any objects in the validate... methods? Violating any of the
other EOF commandments at www.wodev.com?
Chuck
On Jun 16, 2004, at 10:31 PM, Greg Hulands wrote:
Hi,
I have an EO that does not seem to be getting updated in the database.
GiftCertificate cert = null;
try {
cert =
(GiftCertificate)EOUtilities.objectMatchingKeyAndValue(session().defaul
t
EditingContext(), "GiftCertificate", "unlockCode", code);
if (cert != null) {
if (cert.dateRedeemed() != null) {
error = "This Gift Certificate has already been redeemed.";
} else {
cert.setDateRedeemed(new NSTimestamp());
error = "Gift Certificate Redeemed.";
ClientGiftCertificate record = new ClientGiftCertificate();
session().defaultEditingContext().insertObject(record);
record.setBalance(cert.amount());
((Session)session()).user().addObjectToBothSidesOfRelationshipWithKey(r
e
cord, "giftCertificates");
record.addObjectToBothSidesOfRelationshipWithKey(cert,
"giftCertificate");
session().defaultEditingContext().saveChanges();
}
} else {
error = "Invalid Gift Certificate Code.";
}
}
The cert object is the one that doesn't get updated. I have logged the
editing context's updatedObjects and it lists nothing after I set the
date redeemed. The record object gets inserted into the database OK, so
there seems to be a problem just with the cert object. I tried setting
the date redeemed twice to see if that had an effect, but it too did
not fix it. I also changed the way I fetched the cert by creating a
qualifier and fetch spec and using the editing context to fetch it -
basically what the eoutil method does. This too didn't fix the problem.
This is really starting to bug me as you can probably tell from the
code, if it does not update the redemption date, you can keep redeeming
the same code, and that is no good for business! :-(
Any help is very much greatly appreciated.
Regards,
Greg
_______________________________________________
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.
_______________________________________________
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.