Re: Validation Exception
Re: Validation Exception
- Subject: Re: Validation Exception
- From: Marcos Trejo Munguia <email@hidden>
- Date: Fri, 18 Aug 2006 09:36:43 -0500
Hi Chuck,
First of all, thanks for your reply! I really appreciate your help.
I'll try to be more specific, I think I'm confusing you, so here I go.
I'm using MultiECLockManager to handle the locking/unlocking of my own editing contexts.
The code that inserts InventoryTransDetail's to the ec and adds them to the to-many relationship
"inventorytransdetails" in an eo of type InventoryTransHeader:
public void addItem() {
boolean addItemFailed = false;
if (productSelected == null) {
errors.takeValueForKey("Product is required", "product");
addItemFailed = true;
}
if (locationSelected == null) {
errors.takeValueForKey("Location is required", "location");
addItemFailed = true;
}
if (quantity == null) {
errors.takeValueForKey("Qty is required", "quantity");
addItemFailed = true;
} else if (quantity.doubleValue() <= 0) {
errors.takeValueForKey("Qty must be greater than 0", "quantity");
addItemFailed = true;
}
if (!addItemFailed) {
InventoryTransDetail transactionDetail = new InventoryTransDetail();
ec.insertObject(transactionDetail);
transaction.addObjectToBothSidesOfRelationshipWithKey(transactionDetail, "inventorytransdetails");
transactionDetail.setTranssign(Constant.ONE);
transactionDetail.setProduct(productSelected);
transactionDetail.setLocation(locationSelected);
transactionDetail.setSecondarylot(secondaryLot);
transactionDetail.setQty(quantity);
}
}
The code that deletes InventoryTransDetail's from the ec and removes them from the to-many relationship
"inventorytransdetails":
public void deleteItem() {
transaction.removeObjectFromBothSidesOfRelationshipWithKey(transactionDetailIterator, "inventorytransdetails");
ec.deleteObject(transactionDetailIterator);
}
The code that prints out the debugging information when the exception is thrown:
System.err.println("Complete Transaction");
for (Enumeration enum = transaction.inventorytransdetails().objectEnumerator(); enum.hasMoreElements(); ) {
System.err.println("\tItem: " + enum.nextElement());
}
System.err.println("Transaction items where product is null");
for (Enumeration enum = EOQualifier.filteredArrayWithQualifier(transaction.inventorytransdetails(), EOQualifier.qualifierWithQualifierFormat("product = nil", null)).objectEnumerator(); enum.hasMoreElements(); ) {
System.err.println("\tItem: " + enum.nextElement());
}
System.err.println("Registered objects where product is null");
for (Enumeration enum = EOQualifier.filteredArrayWithQualifier(EOQualifier.filteredArrayWithQualifier(ec.registeredObjects(), EOQualifier.qualifierWithQualifierFormat("entityName = 'InventoryTransDetail'", null)),
EOQualifier.qualifierWithQualifierFormat("product = nil", null)).objectEnumerator(); enum.hasMoreElements(); ) {
System.err.println("\tItem: " + enum.nextElement());
}
System.err.println("Inserted objects where product is null");
for (Enumeration enum = EOQualifier.filteredArrayWithQualifier(EOQualifier.filteredArrayWithQualifier(ec.insertedObjects(), EOQualifier.qualifierWithQualifierFormat("entityName = 'InventoryTransDetail'", null)),
EOQualifier.qualifierWithQualifierFormat("product = nil", null)).objectEnumerator(); enum.hasMoreElements(); ) {
System.err.println("\tItem: " + enum.nextElement());
}
System.err.println("Deleted objects where product is null");
for (Enumeration enum = EOQualifier.filteredArrayWithQualifier(EOQualifier.filteredArrayWithQualifier(ec.deletedObjects(), EOQualifier.qualifierWithQualifierFormat("entityName = 'InventoryTransDetail'", null)),
EOQualifier.qualifierWithQualifierFormat("product = nil", null)).objectEnumerator(); enum.hasMoreElements(); ) {
System.err.println("\tItem: " + enum.nextElement());
}
Finally the complete output generated by the above code, I added some colors and spaces for better readability:
Complete Transaction
Item: {values = {poreceptiondetail = "null"; lot = 421; prefix = 6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 1; inventorytransheader = "<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty = 10000; secondarylot = "1691"; location = "<Location 1852c7f _EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product = "<Product aff1e8 _EOIntegralKeyGlobalID[Product (java.lang.Integer)212]>"; }; this = "<InventoryTransDetail ce3b01 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -50 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 315; prefix = 6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 2; inventorytransheader = "<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty = 7000; secondarylot = "524"; location = "<Location 1852c7f _EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product = "<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)664]>"; }; this = "<InventoryTransDetail 1b8a6af <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -49 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 316; prefix = 6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 3; inventorytransheader = "<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty = 7000; secondarylot = "525"; location = "<Location 1852c7f _EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product = "<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)664]>"; }; this = "<InventoryTransDetail 1c76cab <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -48 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 317; prefix = 6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 4; inventorytransheader = "<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty = 7000; secondarylot = "526"; location = "<Location 1852c7f _EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product = "<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)664]>"; }; this = "<InventoryTransDetail 1af691b <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -47 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 318; prefix = 6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 5; inventorytransheader = "<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty = 7000; secondarylot = "527"; location = "<Location 1852c7f _EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product = "<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)664]>"; }; this = "<InventoryTransDetail 767237 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -46 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Transaction items where product is null
Registered objects where product is null
Item: {values = {poreceptiondetail = "null"; lot = 0; prefix = 0; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 6; inventorytransheader = "null"; qty = 7000; secondarylot = "528"; location = "null"; product = "null"; }; this = "<InventoryTransDetail 447a24 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -45 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Inserted objects where product is null
Item: {values = {poreceptiondetail = "null"; lot = 0; prefix = 0; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 6; inventorytransheader = "null"; qty = 7000; secondarylot = "528"; location = "null"; product = "null"; }; this = "<InventoryTransDetail 447a24 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -45 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Deleted objects where product is null
On Aug 15, 2006, at 12:06 AM, Chuck Hill wrote:
Hi Marcos,
I am still trying to recover from the flood of messages while I was at WWDC...
On Aug 10, 2006, at 11:43 AM, Marcos Trejo Munguia wrote:
Hello Chuck,
I was finally able to print the contents of ec.insertedObjects(), and here is what I've found:
Complete Transaction
Item: {values = {poreceptiondetail = "null"; lot = 421; prefix = 6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 1; inventorytransheader = "<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty = 10000; secondarylot = "1691"; location = "<Location 1852c7f _EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product = "<Product aff1e8 _EOIntegralKeyGlobalID[Product (java.lang.Integer)212]>"; }; this = "<InventoryTransDetail ce3b01 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -50 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 315; prefix = 6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 2; inventorytransheader = "<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty = 7000; secondarylot = "524"; location = "<Location 1852c7f _EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product = "<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)664]>"; }; this = "<InventoryTransDetail 1b8a6af <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -49 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 316; prefix = 6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 3; inventorytransheader = "<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty = 7000; secondarylot = "525"; location = "<Location 1852c7f _EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product = "<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)664]>"; }; this = "<InventoryTransDetail 1c76cab <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -48 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 317; prefix = 6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 4; inventorytransheader = "<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty = 7000; secondarylot = "526"; location = "<Location 1852c7f _EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product = "<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)664]>"; }; this = "<InventoryTransDetail 1af691b <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -47 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 318; prefix = 6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 5; inventorytransheader = "<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty = 7000; secondarylot = "527"; location = "<Location 1852c7f _EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product = "<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)664]>"; }; this = "<InventoryTransDetail 767237 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -46 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Registered objects where product is null
Item: {values = {poreceptiondetail = "null"; lot = 0; prefix = 0; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>; transsign = 1; lineitem = 6; inventorytransheader = "null"; qty = 7000; secondarylot = "528"; location = "null"; product = "null"; }; this = "<InventoryTransDetail 447a24 <EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -45 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Interestingly, this is lineitem=6, with 1-5 being in the insertedObjects(). It appears that something has moved it out of insertedObjects() and into registeredObject(). As its EOGlobalID is temporary, it properly ought to be in insertedObjects(). I have seen things like this happen when an EC processed notifications during saveChanges() and it was not properly locked. Are you creating your own editing contexts? If so, are you using Project Wonder or the MultiECLockManager to manage locking them?
The other possibility is that deleteObject() is getting called on this InventoryTransDetail. I am not sure if that would result in what you are seeing or not. Is it possible that your code is deleting it? Are any other objects getting deleted during this transaction?
Are you calling revert() on the editing context before starting this transaction? It could be that some other failed transaction is still in the editing context (like a failed delete), and this is causing this to happen.
The first part(Complete Transaction) is the contents of transaction.inventorytransdetails(), and the second one is the contents of ec.registeredObjects() where product is null. As you can see the object where product is null is not part of transaction.inventorytransdetails(). Another interesting thing is that all to-one relationships are set to null, I don't have any idea of how this could have happened. In theory all objects in transaction. inventorytransdetails() should be in ec.registeredObjects().
I am not sure. Inserted objects may not appear there until after saveChanges() has succeeded. I don't recall for certain.
Chuck
_______________________________________________
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