Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334142

Summary: Support Visual Definition and Editing of MappedSuperclass
Product: [WebTools] Dali JPA Tools Reporter: Shaun Smith <shaun.smith>
Component: Diagram EditorAssignee: Stefan Dimov <stefan.dimov>
Status: RESOLVED FIXED QA Contact: Stefan Dimov <stefan.dimov>
Severity: major    
Priority: P3 CC: neil.hauge, petya.sabeva, sergio.e.samayoa
Version: 0.5Flags: petya.sabeva: review+
Target Milestone: 3.2 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 364004    
Attachments:
Description Flags
Mapped superclasses visulization
none
This icon is part of the change submitted with the patch
none
Mapped_superclasses_visulization_v2 none

Description Shaun Smith CLA 2011-01-12 12:35:52 EST
Creation and editing of MappedSuperclasses should be supported in the JPA Diagram editor.  Dragging and dropping an existing MappedSuperclass onto a diagram should simply add the class to the diagram, not result in the current unintuitive result which is the creation of a new Entity (Bug 322514).  Specification of ids, fields, and relationships and other JPA mappings should be supported on a MappedSuperclass just as they are for an Entity.  It should also be possible to change an Entity into a MappedSuperclass and vice versa.
Comment 1 Stefan Dimov CLA 2011-01-13 04:35:00 EST
Shaun, are you sure this is a good idea? Wouldn't this be an overloading of the editor? Consider the following:

1. If we visualize entities along with mapped superclasses then we should visualize 'is-a' relations between them. Having both JPA relations and 'is-a' relations in one diagram would be unintuitive and confusing for the user (in my opinion)

2. Let's for example we have a mapped superclass named MS and an entity E in the diagram and let there be 3 (or more) entities named E1, E2, E3 inheriting MS. Let's now create 1-to-1 unidir relation from MS to E. The diagram should automatically show three more instances of this relation - from E1, E2 and E3. Along with the 'is-a' realtions the picture would become overloaded and confusing for the user.

Perhaps there is another, more smooth way to design and implement this, but I don't see it. If we are going to introduce it we should do it carefully in order not to lose one of the main advantages of the JPA editor - its simplicity and usage easiness.

Neil, what do you think?
Comment 2 Neil Hauge CLA 2011-01-13 09:31:40 EST
I think we need to balance diagram overload concerns with the need to visualize the entire mapping picture.  Without MappedSuperclass, the mapping picture that the user is visualizing could be incomplete in many ways.  I think in this case that presenting this information is more important than the concern of overload.  Luckily, the diagram editor already has the very nice ability to remove elements from the diagram that the user wishes to hide.  I think that with this ability the concern of overload is greatly minimized.  

So, in summary, I definitely think we should visualize MappedSuperclass info.  That said, I don't think we need to visualize all "is-a" relationships, only those specified as MappedSuperclass
Comment 3 Shaun Smith CLA 2011-01-13 09:46:15 EST
Establishing a OneToOne between MS and E should not push down anything to E1, E2, or E3.  This is a mapping defined on MS.  Yes, E1-3 inherit this mapping but they don't define it.  If I defined a basic mapping on MS I wouldn't expect to see that displayed on E1-3 either.  Unfortunately, the limitation of Java source is that when looking at E1 you don't see the MS->E relationship or mapping of that relationship.  The advantage of the diagram editor is that you could visually see that E1-3 inherit from MS and that MS defines a OneToOne to E.  This is just like what you'd see in a UML diagram.  Inheritance plays a significant roll in JPA Mapping and I believe we need the ability to visualize it.
Comment 4 Stefan Dimov CLA 2011-01-13 09:55:26 EST
Ok, seems that we must implement it. I'm just discussing it, because I want to do it the best possible way. I'm still thinking of how and I'm open for suggestions.
Comment 5 Neil Hauge CLA 2011-01-13 10:32:26 EST
(In reply to comment #4)
> Ok, seems that we must implement it. I'm just discussing it, because I want to
> do it the best possible way. I'm still thinking of how and I'm open for
> suggestions.

Discussion is good. :)  I'm sure we can figure out a good solution that will work well.  Shaun is suggesting that inherited mappings defined on a MappedSuperclass will not be visualized on subclasses, which I think makes sense.  It also reduces unnecessary diagram clutter.

I assume drag and drop will simply be, drag a MappedSuperclass onto the diagram and it will appear and denote any relationships to entities already in the diagram.
Comment 6 Shaun Smith CLA 2011-01-13 13:07:54 EST
(In reply to comment #5)
> (In reply to comment #4)

I definitely don't know exactly how this is going to work either! :-)  But like Neil I think we can work the details out.
Comment 7 Stefan Dimov CLA 2011-01-14 17:35:25 EST
> ... Shaun is suggesting that inherited mappings defined on a
> MappedSuperclass will not be visualized on subclasses, which I think makes
> sense.  It also reduces unnecessary diagram clutter.
> I assume drag and drop will simply be, drag a MappedSuperclass onto the diagram
> and it will appear and denote any relationships to entities already in the
> diagram ...

Since this is currently the best idea we should stick to it.
Comment 8 Neil Hauge CLA 2011-10-27 11:16:39 EDT
The 3.2 target now represents the Juno release.
Comment 9 Stefan Dimov CLA 2011-10-30 18:10:40 EDT
*** Bug 362417 has been marked as a duplicate of this bug. ***
Comment 10 Stefan Dimov CLA 2011-11-15 04:21:55 EST
Created attachment 207013 [details]
Mapped superclasses visulization
Comment 11 Stefan Dimov CLA 2011-11-15 04:26:10 EST
This patch allows the user to create and visualize mapped superclasses and entities which inherits them. It also visualizes the 'is-a' relations. It doesn't support creation between already existing (and visualized) persistent object and deletion of an 'is-a'. I will create another bug for the latter.
Comment 12 Stefan Dimov CLA 2011-11-15 04:28:13 EST
Created attachment 207014 [details]
This icon is part of the change submitted with the patch
Comment 13 Stefan Dimov CLA 2011-11-15 04:29:24 EST
Petya, please review and try the patch when you have the time.
Comment 14 Stefan Dimov CLA 2011-11-29 05:41:56 EST
Petya, would you be able to review the patch this week?
Comment 15 Petya Sabeva CLA 2012-03-26 09:48:07 EDT
Created attachment 213179 [details]
Mapped_superclasses_visulization_v2

The original patch is reworked a little, because there was a small bug.
Comment 16 Petya Sabeva CLA 2012-03-26 10:12:12 EDT
The patch is submitted in HEAD