本文整理汇总了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);
}
示例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);
}
}
}
示例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;
}
示例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 );
}
}
示例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);
}
}
}
示例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)));
}
}
示例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));
}