• 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: Polymorphic Relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Polymorphic Relationship


  • Subject: Re: Polymorphic Relationship
  • From: remy <email@hidden>
  • Date: Tue, 28 Nov 2017 09:47:42 +0000
  • Feedback-id: 1.eu-west-1.qLMkdL013duCXQE3E8SaZ3cBmrTvRp8OpMevsMlTH2s=:AmazonSES

Hi Chuck,

How do I this? I think change my method for create my EntitySub but it
interests me to know this solution. Mostly : "discarding all cached knowledge
of EO".

> If that is what you need, then look at the Role design pattern instead
> Where I can find it?

Rémy

> Le 24 nov. 2017 à 19:05, Chuck Hill <email@hidden> a écrit :
>
> Remy,
>
> You *can* get an EO to change its class over time by changing the restricting
> qualifier, discarding all cached knowledge of EO and doing a fetch.  *But*
> that is really, really not recommended.  If that is what you need, then look
> at the Role design pattern instead.  That is probably closer to what you need.
>
> If you just need to create instances of different classes based on a string
> (EntitySub.ENTITY_NAME) then create a factory method that takes the string
> and returns an instance of a sub-class of EntityAbstract.  All of the
> information needed to do this is in the model and can be referenced at
> runtime.  It is quite simple.  The way you are doing it below is just wrong.
>
> Chuck
>
> From: Webobjects-dev
> <webobjects-dev-bounces+chill=email@hidden> on behalf of
> remy <email@hidden>
> Date: Friday, November 24, 2017 at 2:30 AM
> To: "email@hidden" <email@hidden>
> Subject: Polymorphic Relationship
>
> Hi,
>
> I want make an polymorphic entity.
>
> I have an Entity Abstract named "EntityAbstract" and a subclass Entity named
> "EntitySub" where the qualifier is (refEntityName=‘EntitySub').
> I have third Entity named "Relation" that has an relationship with
> "EntitySub".
>
> I have a problem when :
>
> EOEditingContext editingContext = ERXEC.newEditingContext();
>
> int relationID = Integer.valueOf(relation().primaryKeyInTransaction());
>
> EntityAbstract entityAbstract =
> ERXEOControlUtilities.createAndInsertObject(editingContext(),
> EntityAbstract.class);
> entityAbstract.setRefEntityName(EntitySub.ENTITY_NAME);
> entityAbstract.setRefEntityID(relationID);
>
> editingContext().saveChanges();
>
> ERXEOControlUtilities.refreshObject(relation());
> for (EntityAbstract e : relation().entitySubs())
>          System.err.println(e); // Print <your.app.model.EntityAbstract
>
> How to print <Entity pk:"..."> and not <EntityAbstract pk:"..."> ?
>
> I don't want use the class "Entity" for
> ERXEOControlUtilities.createAndInsertObject
>
> Do you have an idea?
>
> I tested :
>
> eo.invalidateAllObjects(); eo.parentObjectStore().invalidateAllObjects();
> eo.rootObjectStore().invalidateAllObjects();
> It does not work...
>
> The project : https://github.com/algodata44/PolymorphicRelationship
> <https://github.com/algodata44/PolymorphicRelationship>
> Use DB H2
>
> Thx

 _______________________________________________
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: Polymorphic Relationship
      • From: Chuck Hill <email@hidden>
References: 
 >Polymorphic Relationship (From: remy <email@hidden>)
 >Re: Polymorphic Relationship (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: New WebObjects book ?
  • Next by Date: Re: Small issue when building Wonder7 javadoc -> ${wonder-version.version} not properly used
  • Previous by thread: Re: Polymorphic Relationship
  • Next by thread: Re: Polymorphic Relationship
  • Index(es):
    • Date
    • Thread