Hey Alex, You rock dude. Well done
Envoyé de mon iPad Le 30 mai 2013 à 16:56, Alexis Tual <[email protected]> a écrit : > And some more generic fix : > > for (EOModel model : ERXModelGroup.defaultGroup().models()) { > for (EOEntity entity : model.entities()) { > for (EORelationship relationship : entity.relationships()) { > EOEntity destination = relationship.destinationEntity(); > if (destination != null && destination.parentEntity() > != null) { > relationship.anyInverseRelationship(); > } > } > } > } > > Alex > > > 2013/5/30 Alexis Tual <[email protected]> >> Ok despite my eyes bleeding and my brain melting, I continued to dig and >> found that at some point that EORelationship#anyInverseRelationship is >> called to order the changes. This can't find an inverse relationship and >> creates one in memory then calls EOEntity#setEdited, setting >> _attributesToSave to null... >> The relationship is between an entity from another model >> "RepartUefEtablissement" and the subentity "Ue", a quick workaround consists >> in calling anyInverseRelationship before the saveChanges() : >> EOEntity entity = EOUtilities.entityForClass(ec, >> EORepartUefEtablissement.class); >> EORelationship relationship = >> entity.relationshipNamed(EORepartUefEtablissement.COMPOSANT_UE.key()); >> relationship.anyInverseRelationship(); >> >> Hope it will help someone else >> >> Alex >> >> >> 2013/5/30 Alexis Tual <[email protected]> >>> Hi list, >>> >>> this one is tedious, in a framework, we have a model with an abstract >>> entity "Composant" and subentities "Ap" and "Ue" mapped with vertical >>> inheritance. >>> In one application, this works with no error. >>> In another app, we have a SQL error when a instance of Ap and Ue are >>> inserted and saved : >>> ----> SQL for AP insertion is OK : >>> INSERT INTO SCO_SCOLARITE.COMPOSANT(ID_COMPOSANT, CODE, LL_COMPOSANT... >>> INSERT INTO SCO_SCOLARITE.AP(TYPE_AP_ID, SEUIL, NB_GROUPES... >>> >>> ----> SQL for Ue insertion is not OK : >>> INSERT INTO SCO_SCOLARITE.COMPOSANT(ID_UE, CODE, LL_COMPOSANT... >>> >>> It should be ID_COMPOSANT... >>> >>> So, I took my jd and digged down EOF, here's my found : >>> when generating SQL, ERXEntity#anyAttributeNamed is called in >>> EOSQLExpression#prepareInsertExpressionWithRow. >>> In this method, when EOEntity#anyAttributeNamed is called for the attribute >>> 'NeededByEOF0' of AP, it returns the right thing : >>> >>> <EOAttribute NeededByEOF0 >>> name : 'NeededByEOF0' >>> definition : 'sco_Composant.id' >>> className : 'java.lang.Number' >>> externalType : 'NUMBER' >>> valueType : 'i' >>> precision : '38' >>> > >>> >>> whereas for the same attribute of UE, it returns null.. and this explains >>> why the primary key of the subentity is taken instead of the one from the >>> parent... >>> So why it returns null ? The responsible is attribute >>> EOEntity#_attributesToSave which is somehow unset... >>> >>> Lachlan Deck or anyone, any ideas ? >>> >>> Any help is appreciated, >>> >>> Alex > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/rnaneon%40me.com > > This email sent to [email protected]
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
