Inheritance and inverse relationships
Hi, I hope everyone had a good Christmas. During processing models and entities I stumbled upon a situation where I get an unexpected result. Basically I have an entity Parent with a subclass Child using single-table inheritance. Then I have another entity Gift that has a relation Parent -- Gift. Both relationships are marked as class attributes so Parent./Child.gifts() and Gift.presentee() return the correct objects. Now I am processing the corresponding EOModel objects and when I have the model for Child doing: EORelationship rel = childModel.relationshipNamed(gifts); EORelationship inverseRelationship = rel.inverseRelationship(); leaves inverseRelationship with a null value though it should have been set to the presentee-relationship. Digging into EORelationship. inverseRelationship() reveals that it compares the entity (Child in this case) with the destination entities from Gift. Too bad that it resolves to Parent so EOF simply says that there is no matching inverse. Seems as a bug to me. It should check for entity equality and then equality with any subclass if present. Any thoughts? I found the method EORelationship.anyInverseRelationship() that returns an internal inverse but of course that is not really useful when calling valueForKey on an object with the returned key name later on. jw ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Inverse Relationships
If I am using the EOGenerator files from WOLips is there not a way to update a relationship without automatically updating the inverse relationship? If I just call setProperty() then the inverse relationship will get called. I had thought if I called setPropertyRelationship() with er.extensions.ERXEnterpriseObject.updateInverseRelationships=false I would get the desired behavior, but it seems that setPropertyRelationship() always updates the inverse relationship. For example: public void setSetasideCodeRelationship(com.ods.wo.bids.db.SetasideCode value) { if (_Bid.LOG.isDebugEnabled()) { _Bid.LOG.debug(updating setasideCode from + setasideCode() + to + value); } if (er .extensions .eof .ERXGenericRecord .InverseRelationshipUpdater.updateInverseRelationships()) { setSetasideCode(value); } else if (value == null) { com.ods.wo.bids.db.SetasideCode oldValue = setasideCode(); if (oldValue != null) { removeObjectFromBothSidesOfRelationshipWithKey(oldValue, setasideCode); } } else { addObjectToBothSidesOfRelationshipWithKey(value, setasideCode); } } So even if er.extensions.ERXEnterpriseObject.updateInverseRelationships is false it still calls either addObjectsToBothSidesOfRelationshipWithKey() or removeObjectFromBothSidesOfRelationshipWithKey(). Is this correct? If so, is there a way to do this through the generated files? Thanks, Frank ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inverse Relationships
Hi Frank, On Apr 28, 2009, at 10:12 AM, Mr. Frank Cobia wrote: If I am using the EOGenerator files from WOLips is there not a way to update a relationship without automatically updating the inverse relationship? If I just call setProperty() then the inverse relationship will get called. I believe this will only update the inverse if you have the er.extensions.ERXEnterpriseObject.updateInverseRelationships=true set. Otherwise it should only call takeStoredValueForKey(aValue, Property) and stop. I had thought if I called setPropertyRelationship() with er.extensions.ERXEnterpriseObject.updateInverseRelationships=false I would get the desired behavior, but it seems that setPropertyRelationship() always updates the inverse relationship. You have it backwards. The setPropertyRelationship() _explicitly_ sets the inverse, and the updateInverseRelationship will have no effect on it. So, in short, if you want to have control over setting one side only of a relationship, use either of the following _Without_ the updateInverseRelationship=true: takeStoredValueForKey(aValue, Key); or setProperty(aValue); Dave For example: public void setSetasideCodeRelationship(com.ods.wo.bids.db.SetasideCode value) { if (_Bid.LOG.isDebugEnabled()) { _Bid.LOG.debug(updating setasideCode from + setasideCode() + to + value); } if (er .extensions .eof .ERXGenericRecord .InverseRelationshipUpdater.updateInverseRelationships()) { setSetasideCode(value); } else if (value == null) { com.ods.wo.bids.db.SetasideCode oldValue = setasideCode(); if (oldValue != null) { removeObjectFromBothSidesOfRelationshipWithKey(oldValue, setasideCode); } } else { addObjectToBothSidesOfRelationshipWithKey(value, setasideCode); } } So even if er.extensions.ERXEnterpriseObject.updateInverseRelationships is false it still calls either addObjectsToBothSidesOfRelationshipWithKey() or removeObjectFromBothSidesOfRelationshipWithKey(). Is this correct? If so, is there a way to do this through the generated files? Thanks, Frank ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com This email sent to webobje...@avendasora.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inverse Relationships
On Apr 28, 2009, at 10:12, Mr. Frank Cobia wrote: If I am using the EOGenerator files from WOLips is there not a way to update a relationship without automatically updating the inverse relationship? For to ones you can use takeStoredValueForKey(...) For to manys you can use includeObjectIntoPropertyWithKey(...) and excludeObjectFromPropertyWithKey(...) None of these methods will touch the inverse relationship. If these methods aren't good enough to do what you want, please elaborate on your situation. F ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inverse Relationships
Thank you. That fixed it. I did have it backwards. Frank On Apr 28, 2009, at 10:23 AM, David Avendasora wrote: Hi Frank, On Apr 28, 2009, at 10:12 AM, Mr. Frank Cobia wrote: If I am using the EOGenerator files from WOLips is there not a way to update a relationship without automatically updating the inverse relationship? If I just call setProperty() then the inverse relationship will get called. I believe this will only update the inverse if you have the er.extensions.ERXEnterpriseObject.updateInverseRelationships=true set. Otherwise it should only call takeStoredValueForKey(aValue, Property) and stop. I had thought if I called setPropertyRelationship() with er.extensions.ERXEnterpriseObject.updateInverseRelationships=false I would get the desired behavior, but it seems that setPropertyRelationship() always updates the inverse relationship. You have it backwards. The setPropertyRelationship() _explicitly_ sets the inverse, and the updateInverseRelationship will have no effect on it. So, in short, if you want to have control over setting one side only of a relationship, use either of the following _Without_ the updateInverseRelationship=true: takeStoredValueForKey(aValue, Key); or setProperty(aValue); Dave For example: public void setSetasideCodeRelationship(com.ods.wo.bids.db.SetasideCode value) { if (_Bid.LOG.isDebugEnabled()) { _Bid.LOG.debug(updating setasideCode from + setasideCode() + to + value); } if (er .extensions .eof .ERXGenericRecord .InverseRelationshipUpdater.updateInverseRelationships()) { setSetasideCode(value); } else if (value == null) { com.ods.wo.bids.db.SetasideCode oldValue = setasideCode(); if (oldValue != null) { removeObjectFromBothSidesOfRelationshipWithKey(oldValue, setasideCode); } } else { addObjectToBothSidesOfRelationshipWithKey(value, setasideCode); } } So even if er.extensions.ERXEnterpriseObject.updateInverseRelationships is false it still calls either addObjectsToBothSidesOfRelationshipWithKey() or removeObjectFromBothSidesOfRelationshipWithKey(). Is this correct? If so, is there a way to do this through the generated files? Thanks, Frank ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com This email sent to webobje...@avendasora.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inverse Relationships
Sorry, I need a little more help. I understand this, but I would like to keep the updateReverseRelationships=true for the app, but in one situation I would like to set the relationship without updating the reverse. Is it possible to do this? Thanks, Frank On Apr 28, 2009, at 10:23 AM, David Avendasora wrote: Hi Frank, On Apr 28, 2009, at 10:12 AM, Mr. Frank Cobia wrote: If I am using the EOGenerator files from WOLips is there not a way to update a relationship without automatically updating the inverse relationship? If I just call setProperty() then the inverse relationship will get called. I believe this will only update the inverse if you have the er.extensions.ERXEnterpriseObject.updateInverseRelationships=true set. Otherwise it should only call takeStoredValueForKey(aValue, Property) and stop. I had thought if I called setPropertyRelationship() with er.extensions.ERXEnterpriseObject.updateInverseRelationships=false I would get the desired behavior, but it seems that setPropertyRelationship() always updates the inverse relationship. You have it backwards. The setPropertyRelationship() _explicitly_ sets the inverse, and the updateInverseRelationship will have no effect on it. So, in short, if you want to have control over setting one side only of a relationship, use either of the following _Without_ the updateInverseRelationship=true: takeStoredValueForKey(aValue, Key); or setProperty(aValue); Dave For example: public void setSetasideCodeRelationship(com.ods.wo.bids.db.SetasideCode value) { if (_Bid.LOG.isDebugEnabled()) { _Bid.LOG.debug(updating setasideCode from + setasideCode() + to + value); } if (er .extensions .eof .ERXGenericRecord .InverseRelationshipUpdater.updateInverseRelationships()) { setSetasideCode(value); } else if (value == null) { com.ods.wo.bids.db.SetasideCode oldValue = setasideCode(); if (oldValue != null) { removeObjectFromBothSidesOfRelationshipWithKey(oldValue, setasideCode); } } else { addObjectToBothSidesOfRelationshipWithKey(value, setasideCode); } } So even if er.extensions.ERXEnterpriseObject.updateInverseRelationships is false it still calls either addObjectsToBothSidesOfRelationshipWithKey() or removeObjectFromBothSidesOfRelationshipWithKey(). Is this correct? If so, is there a way to do this through the generated files? Thanks, Frank ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com This email sent to webobje...@avendasora.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inverse Relationships
currently not directly .. it's an all-or-nothing setting. you would need to remove the inverse relationship from the model to turn it off. you MIGHT be able to manually do a _setUpdateInverseRelationships(false) (or whatever that method is called) on the EO before you set the relationship in question, but make sure you put the thing to turn it back on in a finally block. ms On Apr 28, 2009, at 10:59 AM, Mr. Frank Cobia wrote: Sorry, I need a little more help. I understand this, but I would like to keep the updateReverseRelationships=true for the app, but in one situation I would like to set the relationship without updating the reverse. Is it possible to do this? Thanks, Frank On Apr 28, 2009, at 10:23 AM, David Avendasora wrote: Hi Frank, On Apr 28, 2009, at 10:12 AM, Mr. Frank Cobia wrote: If I am using the EOGenerator files from WOLips is there not a way to update a relationship without automatically updating the inverse relationship? If I just call setProperty() then the inverse relationship will get called. I believe this will only update the inverse if you have the er.extensions.ERXEnterpriseObject.updateInverseRelationships=true set. Otherwise it should only call takeStoredValueForKey(aValue, Property) and stop. I had thought if I called setPropertyRelationship() with er.extensions.ERXEnterpriseObject.updateInverseRelationships=false I would get the desired behavior, but it seems that setPropertyRelationship() always updates the inverse relationship. You have it backwards. The setPropertyRelationship() _explicitly_ sets the inverse, and the updateInverseRelationship will have no effect on it. So, in short, if you want to have control over setting one side only of a relationship, use either of the following _Without_ the updateInverseRelationship=true: takeStoredValueForKey(aValue, Key); or setProperty(aValue); Dave For example: public void setSetasideCodeRelationship(com.ods.wo.bids.db.SetasideCode value) { if (_Bid.LOG.isDebugEnabled()) { _Bid.LOG.debug(updating setasideCode from + setasideCode() + to + value); } if (er .extensions .eof .ERXGenericRecord .InverseRelationshipUpdater.updateInverseRelationships()) { setSetasideCode(value); } else if (value == null) { com.ods.wo.bids.db.SetasideCode oldValue = setasideCode(); if (oldValue != null) { removeObjectFromBothSidesOfRelationshipWithKey(oldValue, setasideCode); } } else { addObjectToBothSidesOfRelationshipWithKey(value, setasideCode); } } So even if er.extensions.ERXEnterpriseObject.updateInverseRelationships is false it still calls either addObjectsToBothSidesOfRelationshipWithKey() or removeObjectFromBothSidesOfRelationshipWithKey(). Is this correct? If so, is there a way to do this through the generated files? Thanks, Frank ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com This email sent to webobje...@avendasora.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40mdimension.com This email sent to msch...@mdimension.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inverse Relationships
Thanks. I was going to just remove the reverse relationship, but there is actually a place where I do a query that uses the inverse relationship. So my solution, which seems to work, is to remove the class property flag for the inverse relationship. The only downside I have come across is that there is then no ERXKey generated for that inverse relationship. Is there a way to have an ERXKey generated for a non-class property or am I stuck adding it by hand? Thanks, Frank On Apr 28, 2009, at 11:06 AM, Mike Schrag wrote: currently not directly .. it's an all-or-nothing setting. you would need to remove the inverse relationship from the model to turn it off. you MIGHT be able to manually do a _setUpdateInverseRelationships(false) (or whatever that method is called) on the EO before you set the relationship in question, but make sure you put the thing to turn it back on in a finally block. ms On Apr 28, 2009, at 10:59 AM, Mr. Frank Cobia wrote: Sorry, I need a little more help. I understand this, but I would like to keep the updateReverseRelationships=true for the app, but in one situation I would like to set the relationship without updating the reverse. Is it possible to do this? Thanks, Frank On Apr 28, 2009, at 10:23 AM, David Avendasora wrote: Hi Frank, On Apr 28, 2009, at 10:12 AM, Mr. Frank Cobia wrote: If I am using the EOGenerator files from WOLips is there not a way to update a relationship without automatically updating the inverse relationship? If I just call setProperty() then the inverse relationship will get called. I believe this will only update the inverse if you have the er.extensions.ERXEnterpriseObject.updateInverseRelationships=true set. Otherwise it should only call takeStoredValueForKey(aValue, Property) and stop. I had thought if I called setPropertyRelationship() with er .extensions.ERXEnterpriseObject.updateInverseRelationships=false I would get the desired behavior, but it seems that setPropertyRelationship() always updates the inverse relationship. You have it backwards. The setPropertyRelationship() _explicitly_ sets the inverse, and the updateInverseRelationship will have no effect on it. So, in short, if you want to have control over setting one side only of a relationship, use either of the following _Without_ the updateInverseRelationship=true: takeStoredValueForKey(aValue, Key); or setProperty(aValue); Dave For example: public void setSetasideCodeRelationship(com.ods.wo.bids.db.SetasideCode value) { if (_Bid.LOG.isDebugEnabled()) { _Bid.LOG.debug(updating setasideCode from + setasideCode() + to + value); } if (er .extensions .eof .ERXGenericRecord .InverseRelationshipUpdater.updateInverseRelationships()) { setSetasideCode(value); } else if (value == null) { com.ods.wo.bids.db.SetasideCode oldValue = setasideCode(); if (oldValue != null) { removeObjectFromBothSidesOfRelationshipWithKey(oldValue, setasideCode); } } else { addObjectToBothSidesOfRelationshipWithKey(value, setasideCode); } } So even if er.extensions.ERXEnterpriseObject.updateInverseRelationships is false it still calls either addObjectsToBothSidesOfRelationshipWithKey() or removeObjectFromBothSidesOfRelationshipWithKey(). Is this correct? If so, is there a way to do this through the generated files? Thanks, Frank ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com This email sent to webobje...@avendasora.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40mdimension.com This email sent to msch...@mdimension.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/frank.cobia%40f2technology.com This email sent to frank.co...@f2technology.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Inverse Relationships
I would add it by hand to your Entity.java file. ;-) On Apr 28, 2009, at 1:10 PM, Mr. Frank Cobia wrote: Thanks. I was going to just remove the reverse relationship, but there is actually a place where I do a query that uses the inverse relationship. So my solution, which seems to work, is to remove the class property flag for the inverse relationship. The only downside I have come across is that there is then no ERXKey generated for that inverse relationship. Is there a way to have an ERXKey generated for a non-class property or am I stuck adding it by hand? Thanks, Frank On Apr 28, 2009, at 11:06 AM, Mike Schrag wrote: currently not directly .. it's an all-or-nothing setting. you would need to remove the inverse relationship from the model to turn it off. you MIGHT be able to manually do a _setUpdateInverseRelationships(false) (or whatever that method is called) on the EO before you set the relationship in question, but make sure you put the thing to turn it back on in a finally block. ms On Apr 28, 2009, at 10:59 AM, Mr. Frank Cobia wrote: Sorry, I need a little more help. I understand this, but I would like to keep the updateReverseRelationships=true for the app, but in one situation I would like to set the relationship without updating the reverse. Is it possible to do this? Thanks, Frank On Apr 28, 2009, at 10:23 AM, David Avendasora wrote: Hi Frank, On Apr 28, 2009, at 10:12 AM, Mr. Frank Cobia wrote: If I am using the EOGenerator files from WOLips is there not a way to update a relationship without automatically updating the inverse relationship? If I just call setProperty() then the inverse relationship will get called. I believe this will only update the inverse if you have the er.extensions.ERXEnterpriseObject.updateInverseRelationships=true set. Otherwise it should only call takeStoredValueForKey(aValue, Property) and stop. I had thought if I called setPropertyRelationship() with er .extensions.ERXEnterpriseObject.updateInverseRelationships=false I would get the desired behavior, but it seems that setPropertyRelationship() always updates the inverse relationship. You have it backwards. The setPropertyRelationship() _explicitly_ sets the inverse, and the updateInverseRelationship will have no effect on it. So, in short, if you want to have control over setting one side only of a relationship, use either of the following _Without_ the updateInverseRelationship=true: takeStoredValueForKey(aValue, Key); or setProperty(aValue); Dave For example: public void setSetasideCodeRelationship(com.ods.wo.bids.db.SetasideCode value) { if (_Bid.LOG.isDebugEnabled()) { _Bid.LOG.debug(updating setasideCode from + setasideCode() + to + value); } if (er .extensions .eof .ERXGenericRecord .InverseRelationshipUpdater.updateInverseRelationships()) { setSetasideCode(value); } else if (value == null) { com.ods.wo.bids.db.SetasideCode oldValue = setasideCode(); if (oldValue != null) { removeObjectFromBothSidesOfRelationshipWithKey(oldValue, setasideCode); } } else { addObjectToBothSidesOfRelationshipWithKey(value, setasideCode); } } So even if er.extensions.ERXEnterpriseObject.updateInverseRelationships is false it still calls either addObjectsToBothSidesOfRelationshipWithKey() or removeObjectFromBothSidesOfRelationshipWithKey(). Is this correct? If so, is there a way to do this through the generated files? Thanks, Frank ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com This email sent to webobje...@avendasora.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40mdimension.com This email sent to msch...@mdimension.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/frank.cobia%40f2technology.com This email sent to frank.co...@f2technology.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/rparada %40mac.com This email sent to rpar...@mac.com
Re: Inverse Relationships
Is there a way to have an ERXKey generated for a non-class property or am I stuck adding it by hand? sort of defeats the purpose of being non class :) there's nothing magical about them, though -- new ERXKeywhatever(keyname). ms ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Can't get automatic inverse relationships to work
That's good to know. I can only assume that the old code was attempting to avoid an infinite loop. I SEEM to recall that the original code won't infinite loop, but it just wasn't optimal (you ended up doing it twice), so the conditional is just to choose a more optimal path. I think it already deals with the infinite loop inside of itself (since takeStoredValue is called by addObjToBothSides already). But it's been a while :) ms ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Can't get automatic inverse relationships to work
On 09/10/2008, at 10:57 PM, Mike Schrag wrote: Uh... the whole point of the inverse relationship updating was that you could say setAvatar() or addToAvatars() and if would update the reverse for you? Since when is the code below needed now? I'd never want a method that calls itself setFooRelationship as an extra to setFoo(). iPhone development is rotting your brain! :) But yes, I agree ... The problem he had is that he is using the old eogen templates that didn't even have a setAvatar(..) method generated. In the old templates there was ONLY a setAvatarRelationship method (which came from the way way back original templates that all of these were based on -- I forget who originally wrote it), which did an addObjectToBothSides. In the new ones, both methods are supported for backwards compatibility (I had thousands of lines of code that used the setXxxRelationship variant). In the new templates, if you call setXxxRelationship and you do not have inverse updating on, it will behave exactly as it did. If you call it when you DO have inverse relationship updating on, it will simply call through to the straight setXxx method, and in addition, you can just now simply call the setXxx method directly (and bind things to it) and it will do the right thing. So in the new way, you could completely remove your code that calls setXxxRelationship, and those methods could be deprecated. They're only still around to make it easier on people transitioning ... That's good to know. I can only assume that the old code was attempting to avoid an infinite loop. with regards, -- Lachlan Deck ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Can't get automatic inverse relationships to work
Uh... the whole point of the inverse relationship updating was that you could say setAvatar() or addToAvatars() and if would update the reverse for you? Since when is the code below needed now? I'd never want a method that calls itself setFooRelationship as an extra to setFoo(). Cheers, Anjo Am 08.10.2008 um 18:58 schrieb Mike Schrag: Are you using the newer wonder eogen file that talks about automatic inverse updating? Your underscore file for a to-one should look roughly like: public er.attachment.model.ERAttachment avatar() { return (er.attachment.model.ERAttachment)storedValueForKey(avatar); } public void setAvatar(er.attachment.model.ERAttachment value) { takeStoredValueForKey(value, avatar); } public void setAvatarRelationship(er.attachment.model.ERAttachment value) { if (_Person.LOG.isDebugEnabled()) { _Person.LOG.debug(updating avatar from + avatar() + to + value); } if (er .extensions .eof .ERXGenericRecord .InverseRelationshipUpdater.updateInverseRelationships()) { setAvatar(value); } else if (value == null) { er.attachment.model.ERAttachment oldValue = avatar(); if (oldValue != null) { removeObjectFromBothSidesOfRelationshipWithKey(oldValue, avatar); } } else { addObjectToBothSidesOfRelationshipWithKey(value, avatar); } } On Oct 8, 2008, at 12:35 PM, Fredrik Lindgren wrote: I use all this in my app: extend ERXApplication extend ERXSession extend ERXGenericRecord use ERXEC.newEditingContext() In properties i do this: er.extensions.ERXEC.safeLocking=true er.extensions.ERXEnterpriseObject.updateInverseRelationships=true When a set a one relationship from a form (without using the setXXXRelationship) the relationship does not update on the other side! When using the setXXXRelationship it all works. Am I missing something? Regards /Fredrik _ drop, Kålsängsgränd 10 B, 753 19 UPPSALA, Sweden ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40mdimension.com This email sent to [EMAIL PROTECTED] ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/anjo%40krank.net This email sent to [EMAIL PROTECTED] ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Can't get automatic inverse relationships to work
Uh... the whole point of the inverse relationship updating was that you could say setAvatar() or addToAvatars() and if would update the reverse for you? Since when is the code below needed now? I'd never want a method that calls itself setFooRelationship as an extra to setFoo(). iPhone development is rotting your brain! :) But yes, I agree ... The problem he had is that he is using the old eogen templates that didn't even have a setAvatar(..) method generated. In the old templates there was ONLY a setAvatarRelationship method (which came from the way way back original templates that all of these were based on -- I forget who originally wrote it), which did an addObjectToBothSides. In the new ones, both methods are supported for backwards compatibility (I had thousands of lines of code that used the setXxxRelationship variant). In the new templates, if you call setXxxRelationship and you do not have inverse updating on, it will behave exactly as it did. If you call it when you DO have inverse relationship updating on, it will simply call through to the straight setXxx method, and in addition, you can just now simply call the setXxx method directly (and bind things to it) and it will do the right thing. So in the new way, you could completely remove your code that calls setXxxRelationship, and those methods could be deprecated. They're only still around to make it easier on people transitioning ... ms ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Can't get automatic inverse relationships to work
I use all this in my app: extend ERXApplication extend ERXSession extend ERXGenericRecord use ERXEC.newEditingContext() In properties i do this: er.extensions.ERXEC.safeLocking=true er.extensions.ERXEnterpriseObject.updateInverseRelationships=true When a set a one relationship from a form (without using the setXXXRelationship) the relationship does not update on the other side! When using the setXXXRelationship it all works. Am I missing something? Regards /Fredrik _ drop, Kålsängsgränd 10 B, 753 19 UPPSALA, Sweden ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Can't get automatic inverse relationships to work
Are you using the newer wonder eogen file that talks about automatic inverse updating? Your underscore file for a to-one should look roughly like: public er.attachment.model.ERAttachment avatar() { return (er.attachment.model.ERAttachment)storedValueForKey(avatar); } public void setAvatar(er.attachment.model.ERAttachment value) { takeStoredValueForKey(value, avatar); } public void setAvatarRelationship(er.attachment.model.ERAttachment value) { if (_Person.LOG.isDebugEnabled()) { _Person.LOG.debug(updating avatar from + avatar() + to + value); } if (er .extensions .eof .ERXGenericRecord .InverseRelationshipUpdater.updateInverseRelationships()) { setAvatar(value); } else if (value == null) { er.attachment.model.ERAttachment oldValue = avatar(); if (oldValue != null) { removeObjectFromBothSidesOfRelationshipWithKey(oldValue, avatar); } } else { addObjectToBothSidesOfRelationshipWithKey(value, avatar); } } On Oct 8, 2008, at 12:35 PM, Fredrik Lindgren wrote: I use all this in my app: extend ERXApplication extend ERXSession extend ERXGenericRecord use ERXEC.newEditingContext() In properties i do this: er.extensions.ERXEC.safeLocking=true er.extensions.ERXEnterpriseObject.updateInverseRelationships=true When a set a one relationship from a form (without using the setXXXRelationship) the relationship does not update on the other side! When using the setXXXRelationship it all works. Am I missing something? Regards /Fredrik _ drop, Kålsängsgränd 10 B, 753 19 UPPSALA, Sweden ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40mdimension.com This email sent to [EMAIL PROTECTED] ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]