Hello Yung-Luen;

A "fetch" using EOFetchSpecification will retrieve fresh data from the database.

If you have an editing context where changes have been made in-memory but not persisted to the database, those changes are not visible to other editing contexts.

An approach you may like to think about is to add an attribute such as "isVisibleFlag" to your entity. This attribute would have a value of 0 (false) or 1 (true). You could avoid data being shown to customers when the flag is set to false. This will require you to use a qualified EOFetchSpecification to obtain your product list rather than an unqualified fetch.

Regards;

On 2/08/2009, at 10:12 PM, Yung-Luen Lan wrote:

Hi,

I'm implementing a back-end of a e-commerce system, which do CRUD on product records.

To return a list of products, I wrote:

        return Product.fetchAllProducts(ec);

To add a new product, I wrote:

        Product p = new Product();
ec.insertObject(p); // the same ec as in Product.fetchAllProducts(ec)
        p.setTitle("New Item");
        return null;

Since I don't want the newly created product object be exposed to customer––especially when the price value is default value zero, I don't save the ec immediately. Instead, I have a save and cancel button to commit the product information.

However, when I add a new product, it's not shown in Product.fetchAllProducts(ec). How can I get all the product objects in an ec nevertheless it has been saved or not? Thanks.

Regards,
yllan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/apl%40lindesay.co.nz

This email sent to [email protected]

___
Andrew Lindesay
www.lindesay.co.nz

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to