当前位置: 首页>>代码示例>>Java>>正文


Java DynamicParameterizedType类代码示例

本文整理汇总了Java中org.hibernate.usertype.DynamicParameterizedType的典型用法代码示例。如果您正苦于以下问题:Java DynamicParameterizedType类的具体用法?Java DynamicParameterizedType怎么用?Java DynamicParameterizedType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DynamicParameterizedType类属于org.hibernate.usertype包,在下文中一共展示了DynamicParameterizedType类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDatabaseSpecificType

import org.hibernate.usertype.DynamicParameterizedType; //导入依赖的package包/类
@Override
public TypeDescriptor getDatabaseSpecificType(Column column) {
    if ("JSONB".equalsIgnoreCase(column.getColumnType())) {
        Properties typeParams = new Properties();
        if(column.getActualJavaType() == Map.class) {
            typeParams.put(DynamicParameterizedType.PARAMETER_TYPE, new ColumnParameterType(column, Map.class));
            return new TypeDescriptor("com.marvinformatics.hibernate.json.JsonUserType", typeParams);
        } else if(column.getActualJavaType() == List.class) {
            typeParams.put(DynamicParameterizedType.PARAMETER_TYPE, new ColumnParameterType(column, Object.class));
            return new TypeDescriptor("com.marvinformatics.hibernate.json.JsonListUserType", typeParams);
        } else {
            logger.warn("Unsupported column data type: " + column.getActualJavaType());
        }
    }
    return super.getDatabaseSpecificType(column);
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:17,代码来源:PostgreSQLDatabasePlatform.java

示例2: setParameterValues

import org.hibernate.usertype.DynamicParameterizedType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void setParameterValues(Properties parameters) {
    if (parameters == null) {
        throw new MappingException("No class or return type defined for type: " + JsonBlobType.class.getName());
    }
    DynamicParameterizedType.ParameterType reader = (DynamicParameterizedType.ParameterType) parameters.get(PARAMETER_TYPE);
    if (reader != null) {
        setJavaTypeDescriptor(new JsonTypeDescriptor<T>(reader.getReturnedClass()));
    } else {
        String className = parameters.getProperty(RETURNED_CLASS);
        if (className == null) {
            throw new MappingException("No class name defined for type: " + JsonBlobType.class.getName());
        }
        try {
            setJavaTypeDescriptor(new JsonTypeDescriptor<T>(ReflectHelper.classForName(className)));
        } catch (ClassNotFoundException e) {
            throw new MappingException("Unable to load class from " + RETURNED_CLASS + " parameter", e);
        }
    }
}
 
开发者ID:hflabs,项目名称:perecoder,代码行数:22,代码来源:JsonBlobType.java

示例3: getType

import org.hibernate.usertype.DynamicParameterizedType; //导入依赖的package包/类
public Type getType() throws MappingException {
	if ( type != null ) {
		return type;
	}

	if ( typeName == null ) {
		throw new MappingException( "No type name" );
	}
	if ( typeParameters != null
			&& Boolean.valueOf( typeParameters.getProperty( DynamicParameterizedType.IS_DYNAMIC ) )
			&& typeParameters.get( DynamicParameterizedType.PARAMETER_TYPE ) == null ) {
		createParameterImpl();
	}

	Type result = mappings.getTypeResolver().heuristicType( typeName, typeParameters );
	if ( result == null ) {
		String msg = "Could not determine type for: " + typeName;
		if ( table != null ) {
			msg += ", at table: " + table.getName();
		}
		if ( columns != null && columns.size() > 0 ) {
			msg += ", for columns: " + columns;
		}
		throw new MappingException( msg );
	}

	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:SimpleValue.java

示例4: createParameterImpl

import org.hibernate.usertype.DynamicParameterizedType; //导入依赖的package包/类
private void createParameterImpl() {
	try {
		String[] columnsNames = new String[columns.size()];
		for ( int i = 0; i < columns.size(); i++ ) {
			Selectable column = columns.get(i);
			if (column instanceof Column){
				columnsNames[i] = ((Column) column).getName();
			}
		}

		final XProperty xProperty = (XProperty) typeParameters.get( DynamicParameterizedType.XPROPERTY );
		// todo : not sure this works for handling @MapKeyEnumerated
		final Annotation[] annotations = xProperty == null
				? null
				: xProperty.getAnnotations();

		typeParameters.put(
				DynamicParameterizedType.PARAMETER_TYPE,
				new ParameterTypeImpl(
						ReflectHelper.classForName(
								typeParameters.getProperty( DynamicParameterizedType.RETURNED_CLASS )
						),
						annotations,
						table.getCatalog(),
						table.getSchema(),
						table.getName(),
						Boolean.valueOf( typeParameters.getProperty( DynamicParameterizedType.IS_PRIMARY_KEY ) ),
						columnsNames
				)
		);
	}
	catch ( ClassNotFoundException cnfe ) {
		throw new MappingException( "Could not create DynamicParameterizedType for type: " + typeName, cnfe );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:SimpleValue.java

示例5: setParameterValues

import org.hibernate.usertype.DynamicParameterizedType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void setParameterValues(Properties parameters) {
    try {
        Class eClass = ReflectHelper.classForName(parameters.getProperty(DynamicParameterizedType.ENTITY));
        Field field = ReflectionUtils.findField(eClass, parameters.getProperty(DynamicParameterizedType.PROPERTY));
        Type fieldType = field.getGenericType();
        if (fieldType instanceof Class || fieldType instanceof ParameterizedType) {
            type = fieldType;
        }
        parseSqlType(field.getAnnotations());
        return;
    } catch (Exception e) {
        LOG.error(e.getMessage());
    }
    final DynamicParameterizedType.ParameterType reader = (DynamicParameterizedType.ParameterType) parameters.get(
            DynamicParameterizedType.PARAMETER_TYPE);
    if (reader != null) {
        type = reader.getReturnedClass();
        parseSqlType(reader.getAnnotationsMethod());
    } else {
        try {
            type = ReflectHelper.classForName((String) parameters.get(CLASS_NAME));
        } catch (ClassNotFoundException exception) {
            throw new HibernateException("class not found", exception);
        }
    }
}
 
开发者ID:slyak,项目名称:spring-data-jpa-extra,代码行数:28,代码来源:JSONType.java

示例6: entityClass

import org.hibernate.usertype.DynamicParameterizedType; //导入依赖的package包/类
public static Class<?> entityClass(Properties properties) {
    try {
        return Class.forName(properties.getProperty(DynamicParameterizedType.ENTITY));
    } catch (ClassNotFoundException ex) {
        throw new IllegalStateException(String.format("Entity class not found: %s", properties.getProperty(DynamicParameterizedType.ENTITY)));
    }
}
 
开发者ID:optionfactory,项目名称:hibernate-json,代码行数:8,代码来源:UserTypes.java

示例7: mappedField

import org.hibernate.usertype.DynamicParameterizedType; //导入依赖的package包/类
public static Field mappedField(Class<?> baseClass, Properties properties) {
    final String fieldName = properties.getProperty(DynamicParameterizedType.PROPERTY);
    for (Class<?> cls = baseClass; cls != null; cls = cls.getSuperclass()) {
        for (Field f : cls.getDeclaredFields()) {
            if (fieldName.equals(f.getName())) {
                return f;
            }
        }
    }
    throw new IllegalStateException(String.format("Entity field not found: %s::%s", baseClass, fieldName));
}
 
开发者ID:optionfactory,项目名称:hibernate-json,代码行数:12,代码来源:UserTypes.java


注:本文中的org.hibernate.usertype.DynamicParameterizedType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。