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 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