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

Bug 338161

Summary: [Validation] Duplicate Entity validation incorrect in some cases
Product: [WebTools] Dali JPA Tools Reporter: Neil Hauge <neil.hauge>
Component: GeneralAssignee: Nan Li <nan.n.li>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P2 CC: paul.fullbright
Version: 3.0   
Target Milestone: 3.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Neil Hauge CLA 2011-02-24 17:34:56 EST
When defining the same entity for the same class in the same or multiple ORM XML files you will get a validation error stating that there are duplicate entities defined in the persistence unit.  This is allowed in EclipseLink and undefined in Generic.

Message:  Duplicate entity "Foo" found in this persistence unit. Each entity must have a unique name within a persistence unit.

We should ensure this message isn't displayed in the described case in EclipseLink as well as Generic.  Usually we would have a warning for portability in Generic, but this is already complicated enough, and I think most providers support this usage.
Comment 1 Paul Fullbright CLA 2011-02-24 17:40:26 EST
Doesn't EclipseLink only support this in the case that an eclipselink-orm.xml is adding/overriding an entity defined in an orm.xml?  i.e. I don't think you can have duplicate entities in *eclipselink-orm.xml* files.

And we don't support that use case.  So shouldn't we leave that error at least until we do support that use case?
Comment 2 Neil Hauge CLA 2011-02-24 18:16:23 EST
(In reply to comment #1)
> Doesn't EclipseLink only support this in the case that an eclipselink-orm.xml
> is adding/overriding an entity defined in an orm.xml?  i.e. I don't think you
> can have duplicate entities in *eclipselink-orm.xml* files.

No...it actually handles the same entity being defined multiple times in orm.xml files.  It will then aggregate the attribute mappings defined in the entities.  In the case of attribute mapping collisions, it seems the last one in wins.  So for this case, we are adding validation when attribute mappings collide.

See bug 204132.
Comment 3 Neil Hauge CLA 2011-02-25 17:16:34 EST
After discussing more, it seems we need validation for these cases given that Dali will no longer provide accurate validation in this configuration.  

The following should be applied when there are duplicate entities defined in any ORM XML files (including EclipseLink ORM XML as we don't yet support the special overriding EL ORM XML).

Generic and EclipseLink platforms
Message Type: Warning
Message: Duplicate entity [0] found in this persistence unit.  This configuration is not supported by the tooling and may result in invalid error messages.
Comment 4 Neil Hauge CLA 2011-03-01 13:43:20 EST
This issue will be addressed in the fix for bug 204132.