• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDictionary and FetchSpecificationNamed usage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDictionary and FetchSpecificationNamed usage


  • Subject: Re: NSDictionary and FetchSpecificationNamed usage
  • From: Dev WO <email@hidden>
  • Date: Wed, 19 Oct 2005 22:54:06 +0200

Dev WO wrote:

Hi Arturo,
thanks, at least it compiles.
But I get a null pointer exception...
I though comparing the primary key would be "faster" or more efficient as it doesn't have to compare the entire object and just request for the PK.
I should send the entire object as a qualifier for the fetch?



Well, EOF is clever that way. If you make a fetchspec that takes an EO as its parameter, EOF automatically figures out what the primary key is and uses that. That means that you, the developer, doesn't need to know or care how to do that.



that would be:
((quantityAvailable <> quantity) and (product = $product))
in the eomodel and
NSDictionary theProduct = new NSDictionary("product", product);
in the code?


Correct.


Maybe I'm viewing it in the wrong way.
Here's what I'd like to do in fact:
-I've got a table "order" with the order references (date, person name, etc)
-I've got another table "item" with the items and it is joined to "order".
What I need to do is when I add more quantity to a product, I'd like to check all the "items" that belongs to this product (I've got a relationship between "the product" and "item"),
and for each item, I'd like to check a couple parameter inside themselves and in their related "order" before doing anything with my provisioning product.



If I were you, I wouldn't directly get the items like that. I'd get the order and get the items from the order. It will be more efficient at the cost of potential stale data. The stale data is easily handled in this specific instance.



Validation is your friend here as well. If you make a method in your EO called validateItem() with your checks in it then EOF will automatically call it and won't let you save if you make a programming error (unless the error is in validateItem :).


You have to learn to think in the object graph, not the SQL tables.

I know, I'm learning pretty much everyday thanks to this list and some books (Chuck;))
I'll get back to some more "learning" after this project, but I've always find more interesting to learn on "real" situation;)



I though I could get directly the array of "item", but maybe I should do it in several steps.


Assuming you have an order, and a properly defined EOModel, your several steps are


    /* @TypeInfo OrderItem */
    NSMutableArray items = order.items();

Done, update your item counts and saveChanges.
I fact I'm starting from a provisioning for a specific product.
So I though about going all the way up from this product and create an array of item of this product which aren't fully provisioned order by the order date.
Then affect the stock and order quantity.


But I maybe I should go from the order and finds all the product of type "product" and then...

I'm not sure it makes that much different.

I still have some "vision" bugs in my head;) it gets better thought:)



What's your opinion?
thanks Arturo
Xavier

Dev WO wrote:


-----
public void provisioningOrder(Product product, ProductProvisioning provisioning) {
CustomerOrderItem aCustomerOrderItem;
NSMutableDictionary theProduct = new NSMutableDictionary();
theProduct = ((NSArray)product.valueForKey("productPK"));
EOFetchSpecification fetchSpec = EOFetchSpecification.fetchSpecificationNamed ("FetchSpecItemSortedByOrderDateForAProductAndRefresh", "CustomerOrderItem");
EOFetchSpecification boundFs = fetchSpec.fetchSpecificationWithQualifierBindings(theProduct);
-----
I just need to fetch the CustomerOrderItem for the specific object product!
My namedFetchSpecification is handling the sorting and some extra qualifier.
Could someone explain me in a human readable language;) what I'm doing wrong? obviously I'm doing something wrong:)
Thanks
Xavier





Well, you shouldn't be using the primary key as one thing.
Another thing is that you're not putting anything into the array.

Try this
NSDictionary theProduct = new NSDictionary("productPK", product);


Or even
    NSMutableDictionary theProduct = new NSMutableDictionary();
    theProduct.setObjectForKey(product, "paramName");

But really, get rid of the primary key from the object so that you can pass the EO without extracting its primary key first.









_______________________________________________ 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
  • Follow-Ups:
    • Re: NSDictionary and FetchSpecificationNamed usage
      • From: Arturo Perez <email@hidden>
References: 
 >NSDictionary and FetchSpecificationNamed usage (From: Dev WO <email@hidden>)
 >Re: NSDictionary and FetchSpecificationNamed usage (From: Arturo Perez <email@hidden>)
 >Re: NSDictionary and FetchSpecificationNamed usage (From: Dev WO <email@hidden>)
 >Re: NSDictionary and FetchSpecificationNamed usage (From: Arturo Perez <email@hidden>)

  • Prev by Date: Re: Set String methods for Flattened Relationship Attributes
  • Next by Date: Re: Localizing time
  • Previous by thread: Re: NSDictionary and FetchSpecificationNamed usage
  • Next by thread: Re: NSDictionary and FetchSpecificationNamed usage
  • Index(es):
    • Date
    • Thread