• 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: Jean-François Veillette <email@hidden>
  • Date: Fri, 24 Nov 2017 15:55:37 -0500

Hi Remy,
I used polymorphic relationship, in my case I used ERXLongPrimaryKeyFactory
(splitting Long primary key numbers into 2 parts, 1 sequence and 1 entity
index), to help EOF a bit.

In the model you describe, I really think you should change it a bit.
- an object should not change class ‘on the fly’, so once an object is
instantiated, it should stay the same,
- Attribute used for qualifying the entity should be set by default and be
immutable.
- what you have here as ‘refEntityName’ can be modelled differently, it can
actually be part of the primary key (see ERXLongPrimaryKeyFactory),

I recommend you to read the thread on ‘Horizontal inheritance to splitting big
database tables to speed up?"
https://lists.apple.com/archives/webobjects-dev/2016/Jul/msg00033.html

I used the ERXLongPrimaryKeyFactory to good results (look at thread above) and
in polymorphic relationship context it is specially great!

jfv

> On Nov 24, 2017, at 5:30 AM, remy <email@hidden> wrote:
>
> 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

 _______________________________________________
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: 
 >Polymorphic Relationship (From: remy <email@hidden>)

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