use of org.hibernate.boot.internal.ClassmateContext in project hibernate-orm by hibernate.
the class AttributeConverterTest method testBasicOperation.
@Test
public void testBasicOperation() {
SimpleValue simpleValue = new SimpleValue(new MetadataBuildingContextTestingImpl());
simpleValue.setJpaAttributeConverterDescriptor(new InstanceBasedConverterDescriptor(new StringClobConverter(), new ClassmateContext()));
simpleValue.setTypeUsingReflection(IrrelevantEntity.class.getName(), "name");
Type type = simpleValue.getType();
assertNotNull(type);
if (!AttributeConverterTypeAdapter.class.isInstance(type)) {
fail("AttributeConverter not applied");
}
AbstractStandardBasicType basicType = assertTyping(AbstractStandardBasicType.class, type);
assertSame(StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor());
assertEquals(Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType());
}
use of org.hibernate.boot.internal.ClassmateContext in project hibernate-orm by hibernate.
the class AutoApplicableConverterDescriptorStandardImpl method resolveMember.
private ResolvedMember resolveMember(XProperty xProperty, MetadataBuildingContext buildingContext) {
final ClassmateContext classmateContext = buildingContext.getBootstrapContext().getClassmateContext();
final ReflectionManager reflectionManager = buildingContext.getBootstrapContext().getReflectionManager();
final ResolvedType declaringClassType = classmateContext.getTypeResolver().resolve(reflectionManager.toClass(xProperty.getDeclaringClass()));
final ResolvedTypeWithMembers declaringClassWithMembers = classmateContext.getMemberResolver().resolve(declaringClassType, null, null);
final Member member = toMember(xProperty);
if (member instanceof Method) {
for (ResolvedMethod resolvedMember : declaringClassWithMembers.getMemberMethods()) {
if (resolvedMember.getName().equals(member.getName())) {
return resolvedMember;
}
}
} else if (member instanceof Field) {
for (ResolvedField resolvedMember : declaringClassWithMembers.getMemberFields()) {
if (resolvedMember.getName().equals(member.getName())) {
return resolvedMember;
}
}
} else {
throw new HibernateException("Unexpected java.lang.reflect.Member type from org.hibernate.annotations.common.reflection.java.JavaXMember : " + member);
}
throw new HibernateException("Could not locate resolved type information for attribute [" + member.getName() + "] from Classmate");
}
Aggregations