• 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
localInstanceOfObject
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

localInstanceOfObject


  • Subject: localInstanceOfObject
  • From: Roger Perryman <email@hidden>
  • Date: Thu, 16 Jul 2015 13:04:32 -0400

Hi All!

I am having an issue with local instancing an EO and I would like some help understanding the problem. I found an old thread started by Kieran Kelleher where he was having similar issues. Mike Schrag had mentioned that EOF couldn't tell if a new object localInstanced from another EC had later been saved in the other EC which could result in collisions so it erred on the side of caution. So I am probably using the method inappropriately. Hopefully someone will point out the problem and offer the correct way.

I've noticed that when I localInstance a new EO (not yet saved to the database) both the WebObjects and WOnder versions return null for the EO. It seems odd for the method to return null if it is a new method. I wrote a customized version that detects if it is a new EO and just returns the original EO. I've been using it for quite some time now and it at least _seemed_ to work better. My use cases must have avoided conflicts.

However, I've recently noticed problems. They may have been there before. I did recently update my computer (OSX 10.10.3) and dev environment to the latest WOnder (6.1.4-SNAPSHOT), Java 8 (1.8.0_45), Eclipse (4.4.2) with matching WOLips. 

I'm creating a new EC because many of the objects in the original EC are disposable and are not intended to be written to the DB, even if they happen to change. The problem is because of passing the original EO to the new EC instead of NULL that would normally be returned but the relationships cannot be NULL. I wrote a clone method for some of the objects for testing but it got very complex very fast because of deeper objects in the relationship. As you can see from my debugging output, all required fields (*'s) are set and relationships are set. 

This group is the objects in the old (original) EC and the original Invoice that has not been saved yet but it has had an oid assigned. It also has a to-many relationship to new ProductItem objects. 

OLD EC
EditingContext: ERXEC@2d334040
Registered [375]: List omitted
Inserted   [  5]: [Invoice PK: 250], [ProductItem PK: 74], [ProductItemPayment PK: 61], 
[ShoppingCart PK: 44], [ShoppingCartProduct PK: 44]
Updated    [  3]: <Account pk:167>, <Practice pk:1>, <User pk:2>
Deleted    [  0]: EMPTY

OLD Invoice: 
Invoice(5bdf1c53) :
globalID                            = <Invoice PK: 250> { pending } 
editingContext                      = ERXEC@2d334040 Added to EC 

Attributes
approvedDeposit                     = NULL
dateRecordCreated                   = Wednesday July 15, 2015 @ 03:19 PM *
dateRecordModified                  = Wednesday July 15, 2015 @ 03:19 PM *
invoiceDate                         = Wednesday July 15, 2015 @ 03:19 PM *
invoiceDiscount                     = NULL
invoiceNumber                       = IJD20150715151938381 *
isActive                            = true *
taxRate                             = 0.07 *
totalFees                           = 0.0 *
totalNonTaxable                     = 0.0 *
totalTaxable                        = 0.0 *
version                             = 1 *

To-One Relationships
toAccount                           = <Account PK: 167> *
toCheckListPostOp                   = NULL
toCheckListPreOp                    = NULL
toCheckListSurgery                  = NULL
toCoordinator                       = <User PK: 2> ( Jane Doe )  *
toInvoiceStatus                     = <InvoiceStatus PK: 1> ( Open )  *
toInvoiceType                       = <InvoiceType PK: 2> ( Invoice )  *
toPractice                          = <Practice PK: 1> ( DEFAULT_PRACTICE )  *
toSurgeryRequest                    = NULL

To-Many Relationships

toProductItems [ 1 ]
1) eoObj = <ProductItem PK: 74> { pending } 

toRequestDetails
No Records

toServiceItems
No Records


This group is the objects in the new EC and the cloned Invoice that has not been saved yet but it has had an oid assigned. It also has a to-many relationship to new ProductItem objects. Note the oid has increased and unique attributes have been adjusted. When I try to save, it fails because the objects associated with ProductItems have a relationship in a different EC (and retain their original oids).

NEW Invoice: 
Invoice(6371d408) :
globalID                            = <Invoice PK: 251> { pending } 
editingContext                      = ERXEC@1c741963 Added to EC, Updated in EC 

Attributes
approvedDeposit                     = NULL
dateRecordCreated                   = Wednesday July 15, 2015 @ 03:30 PM *
dateRecordModified                  = Wednesday July 15, 2015 @ 03:30 PM *
invoiceDate                         = Wednesday July 15, 2015 @ 03:19 PM *
invoiceDiscount                     = NULL
invoiceNumber                       = IJD20150715151938952 *
isActive                            = true *
taxRate                             = 0.07 *
totalFees                           = 0.0 *
totalNonTaxable                     = 0.0 *
totalTaxable                        = 0.0 *
version                             = 1 *

To-One Relationships
toAccount                           = <Account PK: 167> *
toCheckListPostOp                   = NULL
toCheckListPreOp                    = NULL
toCheckListSurgery                  = NULL
toCoordinator                       = <User PK: 2> ( Jane Doe )  *
toInvoiceStatus                     = <InvoiceStatus PK: 1> ( Open )  *
toInvoiceType                       = <InvoiceType PK: 2> ( Invoice )  *
toPractice                          = <Practice PK: 1> ( DEFAULT_PRACTICE )  *
toSurgeryRequest                    = NULL

To-Many Relationships

toProductItems [ 1 ]
1) eoObj = <ProductItem PK: 74> { pending } 

toRequestDetails
No Records

toServiceItems
No Records

NEW ProductItems: 
(
ProductItem(1695d9bc) :
globalID                            = <ProductItem PK: 74> { pending } 
editingContext                      = ERXEC@2d334040 Added to EC, Updated in EC 

Attributes
dateRecordCreated                   = Wednesday July 15, 2015 @ 03:15 PM *
dateRecordModified                  = Wednesday July 15, 2015 @ 03:15 PM *
discountAmount                      = 0.0 *
isActive                            = true *
unitAmount                          = 100.0 *
unitQuantity                        = 1 *
version                             = 1 *

To-One Relationships
toAuthorizedBy                      = NULL
toInvoice                           = <Invoice PK: 250> { pending }
toProduct                           = <Product PK: 3> ( Abdominoplasty Garment )  *

To-Many Relationships

toGiftCards
No Records

toPayments
No Records

toProductItemPayments [ 1 ]
1) eoObj = <ProductItemPayment PK: 61> { pending } 

toShoppingCartProducts [ 1 ]
1) eoObj = <ShoppingCartProduct PK: 44> { pending } 
)

NEW EC
EditingContext: ERXEC@1c741963
Registered [179]: List omitted
Inserted   [  1]: [Invoice PK: 251]
Updated    [  3]: <Account pk:167>, <Practice pk:1>, <User pk:2>
Deleted    [  0]: EMPTY


Is there a correct way to "localInstance" an unsaved EO? Or do I need to restructure the code and perhaps use nested ECs?

Thanks,

Roger

 _______________________________________________
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: localInstanceOfObject
      • From: Musall Maik <email@hidden>
    • Re: localInstanceOfObject
      • From: Aaron Rosenzweig <email@hidden>
  • Prev by Date: Re: WOWODC16 ??
  • Next by Date: Re: localInstanceOfObject
  • Previous by thread: Re: WOWODC16 ??
  • Next by thread: Re: localInstanceOfObject
  • Index(es):
    • Date
    • Thread