本文整理汇总了Java中org.hibernate.type.TypeResolver类的典型用法代码示例。如果您正苦于以下问题:Java TypeResolver类的具体用法?Java TypeResolver怎么用?Java TypeResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeResolver类属于org.hibernate.type包,在下文中一共展示了TypeResolver类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEntityManagerFactory
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
/**
* {@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;
}
开发者ID:m-m-m,项目名称:persistence,代码行数:35,代码来源:HibernatePersistenceProviderWithGenericDatatypeSupport.java
示例2: addFilterDefinitions
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
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();
}
示例3: setParameterValues
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
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() };
}
示例4: getTypeResolver
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
public TypeResolver getTypeResolver() {
return sessionFactoryImplementor.getTypeResolver();
}
示例5: getTypeResolver
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
public TypeResolver getTypeResolver() {
return typeResolver;
}
示例6: TypeLocatorImpl
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
public TypeLocatorImpl(TypeResolver typeResolver) {
this.typeResolver = typeResolver;
}
示例7: getTypeResolver
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
protected TypeResolver getTypeResolver(SessionFactory sessionFactory) {
return ((SessionFactoryImplementor) sessionFactory).getTypeResolver();
}
示例8: addMetadataFromFieldType
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
@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;
}
示例9: getTypeResolver
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
/**
* Retrieve the type resolver in effect.
*
* @return The type resolver.
*/
public TypeResolver getTypeResolver();
示例10: getTypeResolver
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
/**
* Retrieve the {@link Type} resolver associated with this factory.
*
* @return The type resolver
*/
public TypeResolver getTypeResolver();
示例11: getTypeResolver
import org.hibernate.type.TypeResolver; //导入依赖的package包/类
public TypeResolver getTypeResolver();