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

Bug 332673

Summary: [Validation] Need validation when entities have same name but no name attribute explicitly specified
Product: [WebTools] Dali JPA Tools Reporter: Nan Li <nan.n.li>
Component: GeneralAssignee: Nan Li <nan.n.li>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: neil.hauge
Version: unspecifiedFlags: neil.hauge: review+
Target Milestone: 3.0 M5   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch neil.hauge: iplog+

Description Nan Li CLA 2010-12-15 14:20:16 EST
Build Identifier: 20100917-0705

When entities have same name but no name attribute explicitly is specified for them, the duplicate name problem should be reported since the entity name defaults to the unqualified name (short name) of the entity class and entity names are scoped within the persistence unit and must be unique within persistence unit. 

Reproducible: Always

Steps to Reproduce:

1. Create a java class named like Address and save it to a package like
package1
2. Make the create java class an entity with the @Entity annotation or the
<entity> XML element, but without specifying the name attribute
3. Create another java class giving the same name Address to it, but save it
to another package like package2
4. Make the second java class an entity with the @Entity annotation or the
<entity> XML element, but without specifying name attribute
5. Create a persistence unit and add both entities to it
Comment 1 Nan Li CLA 2011-01-06 15:50:42 EST
Created attachment 186223 [details]
Patch
Comment 2 Nan Li CLA 2011-01-06 15:58:51 EST
Created attachment 186225 [details]
Patch
Comment 3 Nan Li CLA 2011-01-06 16:01:10 EST
Comment on attachment 186225 [details]
Patch

New patch. Removed the unused method "xmlClasslNames(MappingFileRef mappingFileRef)"
Comment 4 Nan Li CLA 2011-01-20 12:52:18 EST
Created attachment 187218 [details]
Patch

-Split the big methods to multiple ones and entered them in different java classes
-Fixed the text range and some other issues found during refactoring the code
Comment 5 Nan Li CLA 2011-01-22 14:48:30 EST
Created attachment 187364 [details]
Patch

-Added extra APIs to org.eclipse.jpt.core.context.persistence.PersistenceUnit interface, e.g. getJavaEntities, getOrmEntities, etc.
-Added validation of duplicate mapped classes cross the persistence unit regardless of the mapping types, e.g. define test1.Foo as an entity twice or as both entity and mapped superclass
-Added validation of duplicate entity names as described in this bug. This validation only applies to entity mapping type. The validation takes effect when duplicates exist among java entities, among orm entities, or/and between java entities and orm entities

In both validation cases above, overriding situation was considered. Both validations don't apply to java mapped classes which are overridden by the orm mapped classes.
Comment 6 Neil Hauge CLA 2011-01-23 23:37:14 EST
Patch committed to head.