• 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
Global ID mixup when adding to "many to many" relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Global ID mixup when adding to "many to many" relationship


  • Subject: Global ID mixup when adding to "many to many" relationship
  • From: Jeff Schmitz <email@hidden>
  • Date: Wed, 29 Dec 2010 12:21:27 -0600

Hello,
   I'm not sure how the following can happen, but I seem to have figured out a way to make it so.  My code creates a new EO (user) and then adds an existing EO (this) to a "many to many" relationship of the new EO as shown with added logged messages:

User user = User.createUser(this.editingContext(), password, eMail, first, forumName, last, lastYearUser, userName,  real, thisYear, useFBAccount, useFBLogin);
this.editingContext().saveChanges();
EOGlobalID poolID = this.editingContext().globalIDForObject(this);
EOGlobalID userID = this.editingContext().globalIDForObject(user);
System.out.println("Adding user " + user.name() + " with ID " + userID + " to Pool " + this.name() + " with id " + poolID);
user.addToPoolsRelationship(this);
this.editingContext().saveChanges();

Note that the first saveChanges after creation of the new EO works fine.  But after the second saveChanges I get the below constraint error.  The strange part is that when printing out the ID's of the EO's, it looks like it should be using a User EO with an ID of 1000009.  However, the integrity error makes it look like it tried to add "this" to a user with ID 1000007.  


Dec 29 11:53:24 netBrackets[9999] (Pool.java:407) INFO  com.netbracketsfw.model.Pool  - Adding user Wilma with ID _EOIntegralKeyGlobalID[User (java.lang.Integer)1000009] to Pool VVV0 with id _EOIntegralKeyGlobalID[Pool (java.lang.Integer)1000005]

Dec 29 11:53:24 netBrackets[9999] (ERXDatabaseContextDelegate.java:175) INFO  er.transaction.adaptor.Exceptions  - Database Exception occured: com.webobjects.eoaccess.EOGeneralAdaptorException: EvaluateExpression failed: <com.webobjects.jdbcadaptor._FrontBasePlugIn$FrontbaseExpression: "INSERT INTO "PoolUser"("userId", "poolId") VALUES (1000007, 1000005)" withBindings: >:
    Next exception:SQL State:23       subclass = 00 -- error code: 358 -- msg: Exception condition 358. Integrity constraint violation (PRIMARY KEY, PoolUser.PRIMARY_KEY_PoolUser_userId_poolId(userId=1000007,poolId=1000005)).
    Next exception:SQL State:40       subclass = 00 -- error code: 363 -- msg: Exception condition 363. Transaction rollback.

Finally, I'm using Wonder, with the InverseRelationshipUpdater turned on, i.e. addToPools gets called.

  public void addToPoolsRelationship(com.netbracketsfw.model.Pool object) {
    if (_User.LOG.isDebugEnabled()) {
      _User.LOG.debug("adding " + object + " to pools relationship");
    }
    if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) {
    addToPools(object);
    }
    else {
    addObjectToBothSidesOfRelationshipWithKey(object, "pools");
    }
  }

any ideas what's going on?

Thanks!
Jeff

 _______________________________________________
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: Global ID mixup when adding to "many to many" relationship
      • From: Jesse Tayler <email@hidden>
  • Prev by Date: Re: Old D2W Project Builder projects to new world?
  • Next by Date: Re: Global ID mixup when adding to "many to many" relationship
  • Previous by thread: Re: Old D2W Project Builder projects to new world?
  • Next by thread: Re: Global ID mixup when adding to "many to many" relationship
  • Index(es):
    • Date
    • Thread