Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338161 - [Validation] Duplicate Entity validation incorrect in some cases
Summary: [Validation] Duplicate Entity validation incorrect in some cases
Status: RESOLVED INVALID
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: General (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 7
: P2 normal (vote)
Target Milestone: 3.0   Edit
Assignee: Nan Li CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-24 17:34 EST by Neil Hauge CLA
Modified: 2011-03-01 13:43 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.