mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-20 01:55:02 +00:00
HHH-7627 mirror bugs in annotation binding side
This commit is contained in:
parent
415e68647f
commit
221649d732
@ -41,6 +41,7 @@
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.type.AttributeTypeResolver;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.type.AttributeTypeResolverImpl;
|
||||
@ -271,7 +272,7 @@ protected boolean determineIsLazy(AnnotationInstance associationAnnotation) {
|
||||
|
||||
private String determineReferencedEntityType(AnnotationInstance associationAnnotation, Class<?> referencedAttributeType) {
|
||||
// use the annotated attribute type as default target type
|
||||
String targetTypeName = referencedAttributeType.getName();
|
||||
String targetTypeName = null;
|
||||
|
||||
// unless we have an explicit @Target
|
||||
AnnotationInstance targetAnnotation = JandexHelper.getSingleAnnotation(
|
||||
@ -287,6 +288,12 @@ private String determineReferencedEntityType(AnnotationInstance associationAnnot
|
||||
targetTypeName = targetEntityValue.asClass().name().toString();
|
||||
}
|
||||
|
||||
if( StringHelper.isEmpty( targetTypeName ) && referencedAttributeType!=null ){
|
||||
targetTypeName = referencedAttributeType.getName();
|
||||
} else {
|
||||
getContext().makeMappingException( "Can't find the target type for this collection attribute: "+ getRole() );
|
||||
}
|
||||
|
||||
return targetTypeName;
|
||||
}
|
||||
|
||||
|
@ -294,6 +294,11 @@ private boolean isPersistentMember(Set<String> transientNames, Set<String> expli
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( member instanceof Method && Method.class.cast( member ).getReturnType().equals( void.class ) ){
|
||||
// not a getter
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( transientNames.contains( member.getName() ) ) {
|
||||
return false;
|
||||
}
|
||||
@ -646,6 +651,9 @@ private ResolvedMember findResolvedMember(String name, ResolvedMember[] resolved
|
||||
}
|
||||
|
||||
private Class<?> resolveCollectionValuedReferenceType(ResolvedMember resolvedMember) {
|
||||
if ( resolvedMember.getType().getTypeParameters().isEmpty() ) {
|
||||
return null; // no generic at all
|
||||
}
|
||||
Class<?> type = resolvedMember.getType().getErasedType();
|
||||
if ( Collection.class.isAssignableFrom( type ) ) {
|
||||
return resolvedMember.getType().getTypeParameters().get( 0 ).getErasedType();
|
||||
|
Loading…
x
Reference in New Issue
Block a user