• 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
Re: Vertical inheritance bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vertical inheritance bug


  • Subject: Re: Vertical inheritance bug
  • From: Raymond NANEON <email@hidden>
  • Date: Thu, 30 May 2013 18:14:09 +0200

Hey Alex,

You rock dude.
Well done

Envoyé de mon iPad

Le 30 mai 2013 à 16:56, Alexis Tual <email@hidden> 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@hidden>
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@hidden>
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@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Vertical inheritance bug (From: Alexis Tual <email@hidden>)
 >Re: Vertical inheritance bug (From: Alexis Tual <email@hidden>)
 >Re: Vertical inheritance bug (From: Alexis Tual <email@hidden>)

  • Prev by Date: Re: Vertical inheritance bug
  • Next by Date: jenkins.wocommunity.org down?
  • Previous by thread: Re: Vertical inheritance bug
  • Next by thread: jenkins.wocommunity.org down?
  • Index(es):
    • Date
    • Thread