Example usage for org.hibernate.engine.spi SessionFactoryImplementor getTypeHelper

List of usage examples for org.hibernate.engine.spi SessionFactoryImplementor getTypeHelper

Introduction

In this page you can find the example usage for org.hibernate.engine.spi SessionFactoryImplementor getTypeHelper.

Prototype

TypeHelper getTypeHelper();

Source Link

Document

Retrieve this factory's TypeHelper .

Usage

From source file:com.blazebit.persistence.impl.hibernate.function.HibernateJpqlFunctionAdapter.java

License:Apache License

@Override
public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException {
    SessionFactoryImplementor sfi = (SessionFactoryImplementor) mapping;
    Class<?> argumentClass;

    if (firstArgumentType == null) {
        argumentClass = null;/*from   w  w  w .ja  v a2s  .  c om*/
    } else {
        argumentClass = firstArgumentType.getReturnedClass();
    }

    Class<?> returnType = function.getReturnType(argumentClass);

    if (returnType == null) {
        return null;
    } else if (argumentClass == returnType) {
        return firstArgumentType;
    }

    Type type = sfi.getTypeHelper().basic(returnType);

    if (type != null) {
        return type;
    }

    if (sfi.getClassMetadata(returnType) != null) {
        return sfi.getTypeHelper().entity(returnType);
    }

    return sfi.getTypeHelper().custom(returnType);
}