Re: Polymorphic Relationship

2017-11-24 Thread Jean-François Veillette
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  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  
> How to print  and not  ?
> 
> 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  (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/jean_francois_veillette%40yahoo.ca
> 
> This email sent to jean_francois_veille...@yahoo.ca

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Polymorphic Relationship

2017-11-24 Thread Ken Anderson
“JUST SAY NO”

Seriously, EOF does NOT like changing the inheritance structure of saved 
objects.  Take Chuck’s advice - change your design pattern.

Ken

> On Nov 24, 2017, at 1:05 PM, Chuck Hill  wrote:
> 
> 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 
>  on behalf of 
> remy 
> Date: Friday, November 24, 2017 at 2:30 AM
> To: "webobjects-dev@lists.apple.com" 
> 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   
> How to print  and not  ?
> 
> 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  (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/kenlists%40anderhome.com
> 
> This email sent to kenli...@anderhome.com

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Polymorphic Relationship

2017-11-24 Thread Chuck Hill
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 
 on behalf of remy 

Date: Friday, November 24, 2017 at 2:30 AM
To: "webobjects-dev@lists.apple.com" 
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  and not  ?
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  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Small issue when building Wonder7 javadoc -> ${wonder-version.version} not properly used

2017-11-24 Thread Markus Ruggiero
Building Wonder 7 with ant from terminal works perfectly. However building the 
docs seems not to properly translate ${wonder-version.version} into a nice 
version string but puts it literally into the html files.

Must be a small thing, but it's a bit annoying. Any idea where to look so I can 
fix this? The build process looks a bit convoluted (at least to me) and I am 
not (yet?) the real ant and maven guru.

Thanks
---markus---
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Polymorphic Relationship

2017-11-24 Thread René Bock
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 mailto:r...@algodata.fr>>:


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  and not  ?

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  
(Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/bock%40salient-doremus.de

This email sent to b...@salient-doremus.de

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

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Polymorphic Relationship

2017-11-24 Thread remy
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  and not  ?

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  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com