in core/src/main/java/org/hibernate/ogm/type/impl/TypeTranslatorImpl.java [89:145]
public GridType getType(Type type) {
if ( type == null ) {
return null;
}
//TODO should we cache results? It seems an actual HashMap might be slower but it makes it more robust
// against badly written dialects
GridType dialectType = dialect.overrideType( type );
if ( dialectType != null ) {
return dialectType;
}
else if ( type instanceof SerializableToBlobType ) {
SerializableToBlobType<?> exposedType = (SerializableToBlobType<?>) type;
return new SerializableAsByteArrayType<>( exposedType.getJavaTypeDescriptor() );
}
else if ( type instanceof AttributeConverterTypeAdapter<?> ) {
// Handles JPA AttributeConverter integration logic
return buildAttributeConverterGridTypeAdaptor( (AttributeConverterTypeAdapter<?>) type );
}
else if ( type instanceof AbstractStandardBasicType ) {
AbstractStandardBasicType<?> exposedType = (AbstractStandardBasicType<?>) type;
final GridType gridType = typeConverter.get( exposedType );
if ( gridType == null ) {
throw log.unableToFindGridType( exposedType.getName() );
}
return gridType;
}
else if ( type instanceof CustomType ) {
CustomType cType = (CustomType) type;
final UserType userType = cType.getUserType();
if ( userType instanceof EnumType ) {
EnumType enumType = (EnumType) userType;
//should we cache that (the key must be enumClass / isOrdinal
return new org.hibernate.ogm.type.impl.EnumType( cType, enumType );
}
//let it go it will eventually fail
}
else if ( type instanceof org.hibernate.type.ComponentType ) {
org.hibernate.type.ComponentType componentType = (org.hibernate.type.ComponentType) type;
return new ComponentType( componentType, this );
}
else if ( type instanceof org.hibernate.type.ManyToOneType ) {
//do some stuff
org.hibernate.type.ManyToOneType manyToOneType = (org.hibernate.type.ManyToOneType) type;
return new ManyToOneType( manyToOneType, this );
}
else if ( type instanceof org.hibernate.type.OneToOneType ) {
//do some stuff
org.hibernate.type.OneToOneType oneToOneType = (org.hibernate.type.OneToOneType) type;
return new OneToOneType( oneToOneType, this );
}
else if ( type instanceof org.hibernate.type.CollectionType ) {
return new CollectionType( (org.hibernate.type.CollectionType) type );
}
throw log.unableToFindGridType( type.getClass().getName() );
}