Search in sources :

Example 1 with AbstractSingleColumnStandardBasicType

use of org.hibernate.type.AbstractSingleColumnStandardBasicType in project hibernate-orm by hibernate.

the class ModelBinder method resolveLob.

private void resolveLob(final SingularAttributeSourceBasic attributeSource, SimpleValue value) {
    // Essentially this expects the type to map to a CLOB/NCLOB/BLOB sql type internally and compares.
    if (!value.isLob() && value.getTypeName() != null) {
        final TypeResolver typeResolver = attributeSource.getBuildingContext().getMetadataCollector().getTypeResolver();
        final BasicType basicType = typeResolver.basic(value.getTypeName());
        if (basicType instanceof AbstractSingleColumnStandardBasicType) {
            if (isLob(((AbstractSingleColumnStandardBasicType) basicType).getSqlTypeDescriptor().getSqlType(), null)) {
                value.makeLob();
            }
        }
    }
    // if this maps to CLOB/NCLOB/BLOB then the value will be marked as lob.
    if (!value.isLob()) {
        for (RelationalValueSource relationalValueSource : attributeSource.getRelationalValueSources()) {
            if (ColumnSource.class.isInstance(relationalValueSource)) {
                if (isLob(null, ((ColumnSource) relationalValueSource).getSqlType())) {
                    value.makeLob();
                }
            }
        }
    }
}
Also used : BasicType(org.hibernate.type.BasicType) AbstractSingleColumnStandardBasicType(org.hibernate.type.AbstractSingleColumnStandardBasicType) TypeResolver(org.hibernate.type.TypeResolver) AbstractSingleColumnStandardBasicType(org.hibernate.type.AbstractSingleColumnStandardBasicType) RelationalValueSource(org.hibernate.boot.model.source.spi.RelationalValueSource)

Example 2 with AbstractSingleColumnStandardBasicType

use of org.hibernate.type.AbstractSingleColumnStandardBasicType in project BroadleafCommerce by BroadleafCommerce.

the class GenericEntityDaoImpl method readGenericEntity.

@Override
public <T> T readGenericEntity(Class<T> clazz, Object id) {
    clazz = (Class<T>) DynamicDaoHelperImpl.getNonProxyImplementationClassIfNecessary(clazz);
    Map<String, Object> md = daoHelper.getIdMetadata(clazz, (HibernateEntityManager) em);
    AbstractSingleColumnStandardBasicType type = (AbstractSingleColumnStandardBasicType) md.get("type");
    if (type instanceof LongType) {
        id = Long.parseLong(String.valueOf(id));
    } else if (type instanceof IntegerType) {
        id = Integer.parseInt(String.valueOf(id));
    }
    return em.find(clazz, id);
}
Also used : IntegerType(org.hibernate.type.IntegerType) LongType(org.hibernate.type.LongType) AbstractSingleColumnStandardBasicType(org.hibernate.type.AbstractSingleColumnStandardBasicType)

Aggregations

AbstractSingleColumnStandardBasicType (org.hibernate.type.AbstractSingleColumnStandardBasicType)2 RelationalValueSource (org.hibernate.boot.model.source.spi.RelationalValueSource)1 BasicType (org.hibernate.type.BasicType)1 IntegerType (org.hibernate.type.IntegerType)1 LongType (org.hibernate.type.LongType)1 TypeResolver (org.hibernate.type.TypeResolver)1