HHH-9855 - Ignore non-entity classes listed as "managed classes" in persistence.xml
This commit is contained in:
parent
d0b429dc32
commit
2b89553db5
|
@ -32,6 +32,7 @@ import org.jboss.logging.Logger;
|
||||||
import javax.persistence.AttributeConverter;
|
import javax.persistence.AttributeConverter;
|
||||||
import javax.persistence.Converter;
|
import javax.persistence.Converter;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -97,28 +98,28 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
|
|
||||||
final ClassLoaderService cls = rootMetadataBuildingContext.getBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class );
|
final ClassLoaderService cls = rootMetadataBuildingContext.getBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class );
|
||||||
for ( String className : sources.getAnnotatedClassNames() ) {
|
for ( String className : sources.getAnnotatedClassNames() ) {
|
||||||
final Class clazz = cls.classForName( className );
|
final Class annotatedClass = cls.classForName( className );
|
||||||
final XClass xClass = reflectionManager.toXClass( clazz );
|
categorizeAnnotatedClass( annotatedClass, attributeConverterManager );
|
||||||
// categorize it, based on assumption it is either an AttributeConverter or an entity
|
|
||||||
if ( xClass.isAnnotationPresent( Converter.class ) ) {
|
|
||||||
//noinspection unchecked
|
|
||||||
attributeConverterManager.addAttributeConverter( clazz );
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
xClasses.add( xClass );
|
for ( Class annotatedClass : sources.getAnnotatedClasses() ) {
|
||||||
|
categorizeAnnotatedClass( annotatedClass, attributeConverterManager );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Class annotateClass : sources.getAnnotatedClasses() ) {
|
private void categorizeAnnotatedClass(Class annotatedClass, AttributeConverterManager attributeConverterManager) {
|
||||||
final XClass xClass = reflectionManager.toXClass( annotateClass );
|
final XClass xClass = reflectionManager.toXClass( annotatedClass );
|
||||||
// categorize it, based on assumption it is either an AttributeConverter or an entity
|
// categorize it, based on assumption it does not fall into multiple categories
|
||||||
if ( xClass.isAnnotationPresent( Converter.class ) ) {
|
if ( xClass.isAnnotationPresent( Converter.class ) ) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
attributeConverterManager.addAttributeConverter( annotateClass );
|
attributeConverterManager.addAttributeConverter( annotatedClass );
|
||||||
}
|
}
|
||||||
else {
|
else if ( xClass.isAnnotationPresent( Entity.class )
|
||||||
|
|| xClass.isAnnotationPresent( MappedSuperclass.class ) ) {
|
||||||
xClasses.add( xClass );
|
xClasses.add( xClass );
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
log.debugf( "Encountered a non-categorized annotated class [%s]; ignoring", annotatedClass.getName() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@ public class EntityNonEntityTest extends BaseCoreFunctionalTestCase {
|
||||||
return new Class[]{
|
return new Class[]{
|
||||||
Phone.class,
|
Phone.class,
|
||||||
Voice.class,
|
Voice.class,
|
||||||
|
// Adding Cellular here is a test for HHH-9855
|
||||||
|
Cellular.class,
|
||||||
GSM.class
|
GSM.class
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue