HHH-6552: Modified HibernateMappingProcessor.processImports() to auto-add imports when applicable for all entity elements
This commit is contained in:
parent
714588342d
commit
b636beccc0
|
@ -28,8 +28,10 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hibernate.internal.jaxb.Origin;
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.EntityElement;
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbFetchProfileElement;
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbHibernateMapping;
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbHibernateMapping.JaxbImport;
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbQueryElement;
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbSqlQueryElement;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
@ -195,16 +197,22 @@ public class HibernateMappingProcessor {
|
|||
}
|
||||
|
||||
private void processImports() {
|
||||
if ( mappingRoot().getImport() == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
for ( JaxbHibernateMapping.JaxbImport importValue : mappingRoot().getImport() ) {
|
||||
JaxbHibernateMapping root = mappingRoot();
|
||||
for ( JaxbImport importValue : root.getImport() ) {
|
||||
String className = mappingDocument.getMappingLocalBindingContext().qualifyClassName( importValue.getClazz() );
|
||||
String rename = importValue.getRename();
|
||||
rename = ( rename == null ) ? StringHelper.unqualify( className ) : rename;
|
||||
metadata.addImport( className, rename );
|
||||
}
|
||||
if ( root.isAutoImport() ) {
|
||||
for ( Object obj : root.getClazzOrSubclassOrJoinedSubclass() ) {
|
||||
EntityElement entityElement = ( EntityElement ) obj;
|
||||
String qualifiedName = bindingContext().determineEntityName( entityElement );
|
||||
metadata.addImport( entityElement.getEntityName() == null
|
||||
? entityElement.getName()
|
||||
: entityElement.getEntityName(), qualifiedName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processResultSetMappings() {
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.hibernate.cfg.Configuration;
|
|||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
/**
|
||||
|
@ -43,6 +42,7 @@ public class UnidirectionalManyToOneTest extends BaseCoreFunctionalTestCase {
|
|||
return new String[] { "unidir/manytoone/ParentChild.hbm.xml" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(Configuration cfg) {
|
||||
super.configure( cfg );
|
||||
cfg.setProperty( USE_NEW_METADATA_MAPPINGS, "true");
|
||||
|
@ -90,10 +90,10 @@ public class UnidirectionalManyToOneTest extends BaseCoreFunctionalTestCase {
|
|||
p = c2.getParent();
|
||||
assertEquals( "Marc", p.getName() );
|
||||
t.commit();
|
||||
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
s.createQuery( "delete from org.hibernate.test.unidir.manytoone.Child" ).executeUpdate();
|
||||
s.createQuery( "delete from Child" ).executeUpdate();
|
||||
s.createQuery( "delete from org.hibernate.test.unidir.manytoone.Parent" ).executeUpdate();
|
||||
t.commit();
|
||||
s.close();
|
||||
|
|
Loading…
Reference in New Issue