Java 类org.hibernate.type.TypeResolver 实例源码

项目:persistence    文件:HibernatePersistenceProviderWithGenericDatatypeSupport.java   
/**
 * {@inheritDoc}
 */
@Override
public EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {

  LOGGER.trace("Starting createEntityManagerFactory for persistenceUnitName {}", persistenceUnitName);

  try {
    final EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilderOrNull(persistenceUnitName, properties);
    if (builder == null) {
      LOGGER.trace("Could not obtain matching EntityManagerFactoryBuilder, returning null");
      return null;
    } else {
      EntityManagerFactoryImpl impl = (EntityManagerFactoryImpl) builder;
      TypeResolver typeResolver = impl.getSessionFactory().getTypeResolver();
      return builder.build();
    }
  } catch (PersistenceException pe) {
    throw pe;
  } catch (Exception e) {
    LOGGER.debug("Unable to build entity manager factory", e);
    throw new PersistenceException("Unable to build entity manager factory", e);
  }
  // EntityManagerFactory entityManagerFactory = super.createEntityManagerFactory(persistenceUnitName,
  // properties);
  // if (entityManagerFactory instanceof EntityManagerFactoryImpl) {
  // SessionFactoryImpl sessionFactory = ((EntityManagerFactoryImpl)
  // entityManagerFactory).getSessionFactory();
  // TypeResolver typeResolver = sessionFactory.getTypeResolver();
  // // typeResolver.registerTypeOverride(type, keys);
  // }
  // return entityManagerFactory;
}
项目:openeos    文件:FilterConfigurator.java   
private void addFilterDefinitions(FilterProvider provider, ConfigurationProvider configurationProvider) {
    Configuration conf = configurationProvider.getConfiguration();
    conf.buildMappings();
    Map<?, ?> filterDefinitions = conf.getFilterDefinitions();
    TypeResolver resolver = conf.getTypeResolver();
    for (BasicFilterDefinition filterDef : provider.getFilterDefinitions()) {
        Map<String, Type> paramMapConverted = new HashMap<String, Type>();
        for (Entry<String, String> paramEntry : filterDef.getParameterTypeMap().entrySet()) {
            Type type = resolver.heuristicType(paramEntry.getValue());
            paramMapConverted.put(paramEntry.getKey(), type);
        }
        FilterDefinition definition = new FilterDefinition(filterDef.getName(), filterDef.getDefaultCondition(),
                paramMapConverted);
        LOG.debug("Registering new filter definition with name '{}'", definition.getFilterName());
        if (filterDefinitions.containsKey(definition.getFilterName())) {
            LOG.warn("The configuration already has filter definition with name '{}',  overwriting.",
                    definition.getFilterName());
        }
        conf.addFilterDefinition(definition);
        filterProviderMap.put(definition.getFilterName(), provider);
        Iterator<PersistentClass> classIterator = conf.getClassMappings();
        while (classIterator.hasNext()) {
            PersistentClass persistentClass = classIterator.next();
            provider.addFilterToClassIfNecesary(persistentClass, filterDef);
        }
    }
    configurationProvider.invalidate();
}
项目:jadira    文件:AbstractHeuristicUserType.java   
public void setParameterValues(Properties parameters) {

    @SuppressWarnings("unchecked")
    final AbstractSingleColumnStandardBasicType<? extends Object> heuristicType = (AbstractSingleColumnStandardBasicType<? extends Object>) new TypeResolver().heuristicType(identifierType.getName(), parameters);
    if (heuristicType == null) {
        throw new HibernateException("Unsupported identifier type " + identifierType.getName());
    }

    type = heuristicType;
    sqlTypes = new int[]{ type.sqlType() };
}
项目:lemon    文件:SessionFactoryWrapper.java   
public TypeResolver getTypeResolver() {
    return sessionFactoryImplementor.getTypeResolver();
}
项目:lams    文件:Configuration.java   
public TypeResolver getTypeResolver() {
    return typeResolver;
}
项目:lams    文件:Configuration.java   
public TypeResolver getTypeResolver() {
    return typeResolver;
}
项目:lams    文件:MetadataImpl.java   
public TypeResolver getTypeResolver() {
    return typeResolver;
}
项目:lams    文件:TypeLocatorImpl.java   
public TypeLocatorImpl(TypeResolver typeResolver) {
    this.typeResolver = typeResolver;
}
项目:lams    文件:SessionFactoryImpl.java   
public TypeResolver getTypeResolver() {
    return typeResolver;
}
项目:gorm-hibernate5    文件:HibernateQuery.java   
protected TypeResolver getTypeResolver(SessionFactory sessionFactory) {
    return ((SessionFactoryImplementor) sessionFactory).getTypeResolver();
}
项目:metaworks_framework    文件:MapFieldsFieldMetadataProvider.java   
@Override
public FieldProviderResponse addMetadataFromFieldType(AddMetadataFromFieldTypeRequest addMetadataFromFieldTypeRequest, Map<String, FieldMetadata> metadata) {
    if (!canHandleFieldForTypeMetadata(addMetadataFromFieldTypeRequest, metadata)) {
        return FieldProviderResponse.NOT_HANDLED;
    }
    //look for any map field metadata that was previously added for the requested field
    for (Map.Entry<String, FieldMetadata> entry : addMetadataFromFieldTypeRequest.getPresentationAttributes().entrySet()) {
        if (entry.getKey().startsWith(addMetadataFromFieldTypeRequest.getRequestedPropertyName() + FieldManager.MAPFIELDSEPARATOR)) {
            TypeLocatorImpl typeLocator = new TypeLocatorImpl(new TypeResolver());

            Type myType = null;
            //first, check if an explicit type was declared
            String valueClass = ((BasicFieldMetadata) entry.getValue()).getMapFieldValueClass();
            if (valueClass != null) {
                myType = typeLocator.entity(valueClass);
            }
            if (myType == null) {
                SupportedFieldType fieldType = ((BasicFieldMetadata) entry.getValue()).getExplicitFieldType();
                Class<?> basicJavaType = getBasicJavaType(fieldType);
                if (basicJavaType != null) {
                    myType = typeLocator.basic(basicJavaType);
                }
            }
            if (myType == null) {
                java.lang.reflect.Type genericType = addMetadataFromFieldTypeRequest.getRequestedField().getGenericType();
                if (genericType instanceof ParameterizedType) {
                    ParameterizedType pType = (ParameterizedType) genericType;
                    Class<?> clazz = (Class<?>) pType.getActualTypeArguments()[1];
                    Class<?>[] entities = addMetadataFromFieldTypeRequest.getDynamicEntityDao().getAllPolymorphicEntitiesFromCeiling(clazz);
                    if (!ArrayUtils.isEmpty(entities)) {
                        myType = typeLocator.entity(entities[entities.length-1]);
                    }
                }
            }
            if (myType == null) {
                   throw new IllegalArgumentException("Unable to establish the type for the property (" + entry
                           .getKey() + ")");
            }
            //add property for this map field as if it was a normal field
            super.addMetadataFromFieldType(new AddMetadataFromFieldTypeRequest(addMetadataFromFieldTypeRequest.getRequestedField(),
                    addMetadataFromFieldTypeRequest.getTargetClass(),
                    addMetadataFromFieldTypeRequest.getForeignField(), addMetadataFromFieldTypeRequest.getAdditionalForeignFields(),
                    addMetadataFromFieldTypeRequest.getMergedPropertyType(), addMetadataFromFieldTypeRequest.getComponentProperties(),
                    addMetadataFromFieldTypeRequest.getIdProperty(),
                    addMetadataFromFieldTypeRequest.getPrefix(),
                    entry.getKey(), myType, addMetadataFromFieldTypeRequest.isPropertyForeignKey(),
                    addMetadataFromFieldTypeRequest.getAdditionalForeignKeyIndexPosition(),
                    addMetadataFromFieldTypeRequest.getPresentationAttributes(), entry.getValue(),
                    ((BasicFieldMetadata) entry.getValue()).getExplicitFieldType(),
                    myType.getReturnedClass(), addMetadataFromFieldTypeRequest.getDynamicEntityDao()), metadata);
        }
    }
    return FieldProviderResponse.HANDLED;
}
项目:SparkCommerce    文件:MapFieldsFieldMetadataProvider.java   
@Override
public FieldProviderResponse addMetadataFromFieldType(AddMetadataFromFieldTypeRequest addMetadataFromFieldTypeRequest, Map<String, FieldMetadata> metadata) {
    if (!canHandleFieldForTypeMetadata(addMetadataFromFieldTypeRequest, metadata)) {
        return FieldProviderResponse.NOT_HANDLED;
    }
    //look for any map field metadata that was previously added for the requested field
    for (Map.Entry<String, FieldMetadata> entry : addMetadataFromFieldTypeRequest.getPresentationAttributes().entrySet()) {
        if (entry.getKey().startsWith(addMetadataFromFieldTypeRequest.getRequestedPropertyName() + FieldManager.MAPFIELDSEPARATOR)) {
            TypeLocatorImpl typeLocator = new TypeLocatorImpl(new TypeResolver());

            Type myType = null;
            //first, check if an explicit type was declared
            String valueClass = ((BasicFieldMetadata) entry.getValue()).getMapFieldValueClass();
            if (valueClass != null) {
                myType = typeLocator.entity(valueClass);
            }
            if (myType == null) {
                SupportedFieldType fieldType = ((BasicFieldMetadata) entry.getValue()).getExplicitFieldType();
                Class<?> basicJavaType = getBasicJavaType(fieldType);
                if (basicJavaType != null) {
                    myType = typeLocator.basic(basicJavaType);
                }
            }
            if (myType == null) {
                java.lang.reflect.Type genericType = addMetadataFromFieldTypeRequest.getRequestedField().getGenericType();
                if (genericType instanceof ParameterizedType) {
                    ParameterizedType pType = (ParameterizedType) genericType;
                    Class<?> clazz = (Class<?>) pType.getActualTypeArguments()[1];
                    Class<?>[] entities = addMetadataFromFieldTypeRequest.getDynamicEntityDao().getAllPolymorphicEntitiesFromCeiling(clazz);
                    if (!ArrayUtils.isEmpty(entities)) {
                        myType = typeLocator.entity(entities[entities.length-1]);
                    }
                }
            }
            if (myType == null) {
                   throw new IllegalArgumentException("Unable to establish the type for the property (" + entry
                           .getKey() + ")");
            }
            //add property for this map field as if it was a normal field
            super.addMetadataFromFieldType(new AddMetadataFromFieldTypeRequest(addMetadataFromFieldTypeRequest.getRequestedField(),
                    addMetadataFromFieldTypeRequest.getTargetClass(),
                    addMetadataFromFieldTypeRequest.getForeignField(), addMetadataFromFieldTypeRequest.getAdditionalForeignFields(),
                    addMetadataFromFieldTypeRequest.getMergedPropertyType(), addMetadataFromFieldTypeRequest.getComponentProperties(),
                    addMetadataFromFieldTypeRequest.getIdProperty(),
                    addMetadataFromFieldTypeRequest.getPrefix(),
                    entry.getKey(), myType, addMetadataFromFieldTypeRequest.isPropertyForeignKey(),
                    addMetadataFromFieldTypeRequest.getAdditionalForeignKeyIndexPosition(),
                    addMetadataFromFieldTypeRequest.getPresentationAttributes(), entry.getValue(),
                    ((BasicFieldMetadata) entry.getValue()).getExplicitFieldType(),
                    myType.getReturnedClass(), addMetadataFromFieldTypeRequest.getDynamicEntityDao()), metadata);
        }
    }
    return FieldProviderResponse.HANDLED;
}
项目:blcdemo    文件:MapFieldsFieldMetadataProvider.java   
@Override
public FieldProviderResponse addMetadataFromFieldType(AddMetadataFromFieldTypeRequest addMetadataFromFieldTypeRequest, Map<String, FieldMetadata> metadata) {
    if (!canHandleFieldForTypeMetadata(addMetadataFromFieldTypeRequest, metadata)) {
        return FieldProviderResponse.NOT_HANDLED;
    }
    //look for any map field metadata that was previously added for the requested field
    for (Map.Entry<String, FieldMetadata> entry : addMetadataFromFieldTypeRequest.getPresentationAttributes().entrySet()) {
        if (entry.getKey().startsWith(addMetadataFromFieldTypeRequest.getRequestedPropertyName() + FieldManager.MAPFIELDSEPARATOR)) {
            TypeLocatorImpl typeLocator = new TypeLocatorImpl(new TypeResolver());

            Type myType = null;
            //first, check if an explicit type was declared
            String valueClass = ((BasicFieldMetadata) entry.getValue()).getMapFieldValueClass();
            if (valueClass != null) {
                myType = typeLocator.entity(valueClass);
            }
            if (myType == null) {
                SupportedFieldType fieldType = ((BasicFieldMetadata) entry.getValue()).getExplicitFieldType();
                Class<?> basicJavaType = getBasicJavaType(fieldType);
                if (basicJavaType != null) {
                    myType = typeLocator.basic(basicJavaType);
                }
            }
            if (myType == null) {
                java.lang.reflect.Type genericType = addMetadataFromFieldTypeRequest.getRequestedField().getGenericType();
                if (genericType instanceof ParameterizedType) {
                    ParameterizedType pType = (ParameterizedType) genericType;
                    Class<?> clazz = (Class<?>) pType.getActualTypeArguments()[1];
                    Class<?>[] entities = addMetadataFromFieldTypeRequest.getDynamicEntityDao().getAllPolymorphicEntitiesFromCeiling(clazz);
                    if (!ArrayUtils.isEmpty(entities)) {
                        myType = typeLocator.entity(entities[entities.length-1]);
                    }
                }
            }
            if (myType == null) {
                   throw new IllegalArgumentException("Unable to establish the type for the property (" + entry
                           .getKey() + ")");
            }
            //add property for this map field as if it was a normal field
            super.addMetadataFromFieldType(new AddMetadataFromFieldTypeRequest(addMetadataFromFieldTypeRequest.getRequestedField(),
                    addMetadataFromFieldTypeRequest.getTargetClass(),
                    addMetadataFromFieldTypeRequest.getForeignField(), addMetadataFromFieldTypeRequest.getAdditionalForeignFields(),
                    addMetadataFromFieldTypeRequest.getMergedPropertyType(), addMetadataFromFieldTypeRequest.getComponentProperties(),
                    addMetadataFromFieldTypeRequest.getIdProperty(),
                    addMetadataFromFieldTypeRequest.getPrefix(),
                    entry.getKey(), myType, addMetadataFromFieldTypeRequest.isPropertyForeignKey(),
                    addMetadataFromFieldTypeRequest.getAdditionalForeignKeyIndexPosition(),
                    addMetadataFromFieldTypeRequest.getPresentationAttributes(), entry.getValue(),
                    ((BasicFieldMetadata) entry.getValue()).getExplicitFieldType(),
                    myType.getReturnedClass(), addMetadataFromFieldTypeRequest.getDynamicEntityDao()), metadata);
        }
    }
    return FieldProviderResponse.HANDLED;
}
项目:hibernate-dynamic-dialects    文件:SessionFactoryImpl.java   
public TypeResolver getTypeResolver() {
    return typeResolver;
}
项目:lams    文件:Mappings.java   
/**
 * Retrieve the type resolver in effect.
 *
 * @return The type resolver.
 */
public TypeResolver getTypeResolver();
项目:lams    文件:SessionFactoryImplementor.java   
/**
 * Retrieve the {@link Type} resolver associated with this factory.
 *
 * @return The type resolver
 */
public TypeResolver getTypeResolver();
项目:lams    文件:MetadataImplementor.java   
public TypeResolver getTypeResolver();