• 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: René Bock <email@hidden>
  • Date: Fri, 24 Nov 2017 11:14:09 +0000
  • Thread-topic: Polymorphic Relationship

Hi Remy,

Is there a reason, not to use createAndInsertObject(ec, SubEntity.class) ?

In think, the WO way would be sth like:

SubEntiy sub = ERXEOControlUtilities.createAndInsertObject(ec, SubEntity.class);
sub.addObjectToBothSidesOfRelationshipWithKey(relation(), "refEntity");

ec.saveChanges();

If you really want to model a polymorphic relationship, the destination of the
relationship "refEntity" should be EntityAbstract.



Am 24.11.2017 um 11:30 schrieb remy <email@hidden<mailto:email@hidden>>:


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
Use DB H2

Thx
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list
(email@hidden<mailto:email@hidden>)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

Mit freundlichen Grüßen

René Bock

--
Telefon: +49 69 650096 18

salient GmbH, Lindleystraße 12, 60314 Frankfurt
Telefon Zentrale: 069 / 65 00 96 - 0  |
www.salient-doremus.de<http://www.salient-doremus.de>

 _______________________________________________
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: Polymorphic Relationship
  • Next by Date: Small issue when building Wonder7 javadoc -> ${wonder-version.version} not properly used
  • Previous by thread: Polymorphic Relationship
  • Next by thread: Re: Polymorphic Relationship
  • Index(es):
    • Date
    • Thread