From: Barry K. (JIRA) <no...@at...> - 2006-05-11 13:15:11
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-341?page=comments#action_23081 ] Barry Kaplan commented on ANN-341: ---------------------------------- I could not find anything in the spec which states the default value for 'name' /must/ be the unqualified class name? Did I just miss it? Or is this is a hibernate specific decision? Do you know how it is recommended to handle the case when a product is including two thirdparty jars with conflicting unqualified @Entity's where changing the source is not an option? This is the case that I am concerned about wrt this issue. > EntityBinder is always auto-import > ---------------------------------- > > Key: ANN-341 > URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-341 > Project: Hibernate Annotations > Type: Bug > Components: binder > Versions: 3.1.0.Beta10 > Reporter: Barry Kaplan > > > I have two classes with the same unqualified name but in different packages: > package org.opentrader.foo; > @Entity > class Order { ... } > package org.opentrader.bar; > @Entity > class Order { ... } > These classes are added using AnnotationConfiguration.addAnnotatedClass(). > But when these classes are added, EntityBinder.bindEjb3Annotation will use the unqualified name as the key for storing the entity: > class EntityBinder { > ... > if ( AnnotationBinder.isDefault( ejb3Ann.name() ) ) { > name = StringHelper.unqualify( annotatedClass.getName() ); > } > else { > name = ejb3Ann.name(); > } > ... > try { > mappings.addImport( persistentClass.getEntityName(), name ); > } > catch (MappingException me) { > throw new AnnotationException( "Use of the same entity name twice: " + name ); > } > } > class Mappings { > public void addImport(...) { > String existing = (String) imports.put(rename, className); > } > } > When HbmBinder adds imports, it has logic to /not/ add the class using its unqualified name: > class HbmBinder.addImport() { > mappings.addImport( entity.getEntityName(), entity.getEntityName() ); > if ( mappings.isAutoImport() && entity.getEntityName().indexOf( '.' ) > 0 ) { > mappings.addImport( > entity.getEntityName(), > StringHelper.unqualify( entity.getEntityName() ) > ); > } > } > Should not EntityBinder also explicitly support auto-import? -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |