當前位置: 首頁>>代碼示例>>Java>>正文


Java UserType類代碼示例

本文整理匯總了Java中org.hibernate.usertype.UserType的典型用法代碼示例。如果您正苦於以下問題:Java UserType類的具體用法?Java UserType怎麽用?Java UserType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UserType類屬於org.hibernate.usertype包,在下文中一共展示了UserType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: byClass

import org.hibernate.usertype.UserType; //導入依賴的package包/類
public Type byClass(Class clazz, Properties parameters) {
	if ( Type.class.isAssignableFrom( clazz ) ) {
		return type( clazz, parameters );
	}

	if ( CompositeUserType.class.isAssignableFrom( clazz ) ) {
		return customComponent( clazz, parameters );
	}

	if ( UserType.class.isAssignableFrom( clazz ) ) {
		return custom( clazz, parameters );
	}

	if ( Lifecycle.class.isAssignableFrom( clazz ) ) {
		// not really a many-to-one association *necessarily*
		return manyToOne( clazz.getName() );
	}

	if ( Serializable.class.isAssignableFrom( clazz ) ) {
		return serializable( clazz );
	}

	return null;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:TypeFactory.java

示例2: custom

import org.hibernate.usertype.UserType; //導入依賴的package包/類
/**
 * @deprecated Only for use temporary use by {@link org.hibernate.Hibernate}
 */
@Deprecated
   public static CustomType custom(Class<UserType> typeClass, Properties parameters, TypeScope scope) {
	try {
		UserType userType = typeClass.newInstance();
		injectParameters( userType, parameters );
		return new CustomType( userType );
	}
	catch ( Exception e ) {
		throw new MappingException( "Unable to instantiate custom type: " + typeClass.getName(), e );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:TypeFactory.java

示例3: CustomType

import org.hibernate.usertype.UserType; //導入依賴的package包/類
public CustomType(UserType userType, String[] registrationKeys) throws MappingException {
	this.userType = userType;
	this.name = userType.getClass().getName();
	this.types = userType.sqlTypes();
	this.dictatedSizes = Sized.class.isInstance( userType )
			? ( (Sized) userType ).dictatedSizes()
			: new Size[ types.length ];
	this.defaultSizes = Sized.class.isInstance( userType )
			? ( (Sized) userType ).defaultSizes()
			: new Size[ types.length ];
	this.customLogging = LoggableUserType.class.isInstance( userType );
	this.registrationKeys = registrationKeys;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:CustomType.java

示例4: CustomType

import org.hibernate.usertype.UserType; //導入依賴的package包/類
public CustomType(Class userTypeClass, Properties parameters) throws MappingException {

		if ( !UserType.class.isAssignableFrom( userTypeClass ) ) {
			throw new MappingException(
					"Custom type does not implement UserType: " +
					userTypeClass.getName()
				);
		}

		name = userTypeClass.getName();

		try {
			userType = ( UserType ) userTypeClass.newInstance();
		}
		catch ( InstantiationException ie ) {
			throw new MappingException(
					"Cannot instantiate custom type: " +
					userTypeClass.getName()
				);
		}
		catch ( IllegalAccessException iae ) {
			throw new MappingException(
					"IllegalAccessException trying to instantiate custom type: " +
					userTypeClass.getName()
				);
		}

        TypeFactory.injectParameters( userType, parameters );
		types = userType.sqlTypes();

		customLogging = LoggableUserType.class.isAssignableFrom( userTypeClass );
	}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:33,代碼來源:CustomType.java

示例5: checkForCreateListTypeType

import org.hibernate.usertype.UserType; //導入依賴的package包/類
private void checkForCreateListTypeType(Configuration conf, final Class<?> propertyType) throws NoSuchMethodException,
		IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
	if (!listTypeProxyCreatedSet.contains(propertyType)) {
		ProxyFactory factory = new ProxyFactory();
		factory.setSuperclass(ListTypeUserType.class);
		factory.setFilter(new MethodFilter() {

			@Override
			public boolean isHandled(Method method) {
				return Modifier.isAbstract(method.getModifiers());
			}
		});
		MethodHandler handler = new MethodHandler() {

			@Override
			public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable {
				if (thisMethod.getName().equals("returnedClass") && args.length == 0) {
					LOG.debug("Handling method returnedClass() of type ListTypeUserType", thisMethod);
					return propertyType;
				} else {
					throw new UnsupportedOperationException();
				}
			}

		};
		Object type = factory.create(new Class<?>[0], new Object[0], handler);
		conf.registerTypeOverride((UserType) type, new String[] { propertyType.getSimpleName(), propertyType.getName() });
		listTypeProxyCreatedSet.add(propertyType);
	}
}
 
開發者ID:frincon,項目名稱:openeos,代碼行數:31,代碼來源:BundleModelClassConfigurator.java

示例6: registerTypeOverride

import org.hibernate.usertype.UserType; //導入依賴的package包/類
public void registerTypeOverride(UserType type, String[] keys) {
	getTypeResolver().registerTypeOverride( type, keys );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:4,代碼來源:Configuration.java

示例7: registerTypeOverride

import org.hibernate.usertype.UserType; //導入依賴的package包/類
public void registerTypeOverride(UserType type, String[] keys) {
	basicTypeRegistry.register( type, keys );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:4,代碼來源:TypeResolver.java

示例8: getUserType

import org.hibernate.usertype.UserType; //導入依賴的package包/類
public UserType getUserType() {
	return userType;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:4,代碼來源:CustomType.java

示例9: register

import org.hibernate.usertype.UserType; //導入依賴的package包/類
public void register(UserType type, String[] keys) {
	register( new CustomType( type, keys ) );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:4,代碼來源:BasicTypeRegistry.java

示例10: newLegacySessionFactory

import org.hibernate.usertype.UserType; //導入依賴的package包/類
private SessionFactory newLegacySessionFactory() {
    Properties properties = properties();
    Configuration configuration = new Configuration().addProperties(properties);
    for (Class<?> entityClass : entities()) {
        configuration.addAnnotatedClass(entityClass);
    }
    String[] packages = packages();
    if (packages != null) {
        for (String scannedPackage : packages) {
            configuration.addPackage(scannedPackage);
        }
    }
    String[] resources = resources();
    if (resources != null) {
        for (String resource : resources) {
            configuration.addResource(resource);
        }
    }
    Interceptor interceptor = interceptor();
    if (interceptor != null) {
        configuration.setInterceptor(interceptor);
    }

    final List<Type> additionalTypes = additionalTypes();
    if (additionalTypes != null) {
        configuration.registerTypeContributor((typeContributions, serviceRegistry) -> {
            additionalTypes.stream().forEach(type -> {
                if (type instanceof BasicType) {
                    typeContributions.contributeType((BasicType) type);
                } else if (type instanceof UserType) {
                    typeContributions.contributeType((UserType) type);
                } else if (type instanceof CompositeUserType) {
                    typeContributions.contributeType((CompositeUserType) type);
                }
            });
        });
    }
    return configuration.buildSessionFactory(
            new StandardServiceRegistryBuilder()
                    .applySettings(properties)
                    .build()
    );
}
 
開發者ID:vladmihalcea,項目名稱:hibernate-types,代碼行數:44,代碼來源:AbstractTest.java

示例11: newSessionFactory

import org.hibernate.usertype.UserType; //導入依賴的package包/類
private SessionFactory newSessionFactory() {
    Properties properties = properties();
    Configuration configuration = new Configuration().addProperties(properties);
    for (Class<?> entityClass : entities()) {
        configuration.addAnnotatedClass(entityClass);
    }
    String[] packages = packages();
    if (packages != null) {
        for (String scannedPackage : packages) {
            configuration.addPackage(scannedPackage);
        }
    }
    String[] resources = resources();
    if (resources != null) {
        for (String resource : resources) {
            configuration.addResource(resource);
        }
    }
    Interceptor interceptor = interceptor();
    if (interceptor != null) {
        configuration.setInterceptor(interceptor);
    }

    final List<Type> additionalTypes = additionalTypes();
    if (additionalTypes != null) {
        configuration.registerTypeContributor(new TypeContributor() {
            @Override
            public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
                for (Type type : additionalTypes) {
                    if (type instanceof BasicType) {
                        typeContributions.contributeType((BasicType) type);
                    } else if (type instanceof UserType) {
                        typeContributions.contributeType((UserType) type, new String[]{type.getName()});
                    } else if (type instanceof CompositeUserType) {
                        typeContributions.contributeType((CompositeUserType) type, new String[]{type.getName()});
                    }
                }
            }
        });
    }
    return configuration.buildSessionFactory(
            new StandardServiceRegistryBuilder()
                    .applySettings(properties)
                    .build()
    );
}
 
開發者ID:vladmihalcea,項目名稱:hibernate-types,代碼行數:47,代碼來源:AbstractTest.java

示例12: newLegacySessionFactory

import org.hibernate.usertype.UserType; //導入依賴的package包/類
private SessionFactory newLegacySessionFactory() {
    Properties properties = properties();
    Configuration configuration = new Configuration().addProperties(properties);
    for (Class<?> entityClass : entities()) {
        configuration.addAnnotatedClass(entityClass);
    }
    String[] packages = packages();
    if (packages != null) {
        for (String scannedPackage : packages) {
            configuration.addPackage(scannedPackage);
        }
    }
    String[] resources = resources();
    if (resources != null) {
        for (String resource : resources) {
            configuration.addResource(resource);
        }
    }
    Interceptor interceptor = interceptor();
    if (interceptor != null) {
        configuration.setInterceptor(interceptor);
    }

    final List<Type> additionalTypes = additionalTypes();
    if (additionalTypes != null) {
        configuration.registerTypeContributor(new TypeContributor() {
            @Override
            public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
                for (Type type : additionalTypes) {
                    if (type instanceof BasicType) {
                        typeContributions.contributeType((BasicType) type);
                    } else if (type instanceof UserType) {
                        typeContributions.contributeType((UserType) type);
                    } else if (type instanceof CompositeUserType) {
                        typeContributions.contributeType((CompositeUserType) type);
                    }
                }
            }
        });
    }
    return configuration.buildSessionFactory(
            new StandardServiceRegistryBuilder()
                    .applySettings(properties)
                    .build()
    );
}
 
開發者ID:vladmihalcea,項目名稱:hibernate-types,代碼行數:47,代碼來源:AbstractTest.java

示例13: heuristicType

import org.hibernate.usertype.UserType; //導入依賴的package包/類
/**
 * Uses heuristics to deduce a Hibernate type given a string naming the type or Java class.
 * Return an instance of <tt>org.hibernate.type.Type</tt>.
 */
public static Type heuristicType(String typeName, Properties parameters)
		throws MappingException {
	Type type = TypeFactory.basic( typeName );
	if ( type == null ) {
		Class typeClass;
		try {
			typeClass = ReflectHelper.classForName( typeName );
		}
		catch (ClassNotFoundException cnfe) {
			typeClass = null;
		}
		if ( typeClass != null ) {
			if ( Type.class.isAssignableFrom( typeClass ) ) {
				try {
					type = (Type) typeClass.newInstance();
				}
				catch (Exception e) {
					throw new MappingException( 
							"Could not instantiate Type: " + typeClass.getName(),
							e 
						);
				}
				injectParameters(type, parameters);
			}
			else if ( CompositeUserType.class.isAssignableFrom( typeClass ) ) {
				type = new CompositeCustomType( typeClass, parameters );
			}
			else if ( UserType.class.isAssignableFrom( typeClass ) ) {
				type = new CustomType( typeClass, parameters );
			}
			else if ( Lifecycle.class.isAssignableFrom( typeClass ) ) {
				type = Hibernate.entity( typeClass );
			}
			else if ( Serializable.class.isAssignableFrom( typeClass ) ) {
				type = Hibernate.serializable( typeClass );
			}
		}
	}
	return type;

}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:46,代碼來源:TypeFactory.java

示例14: getGeometryUserType

import org.hibernate.usertype.UserType; //導入依賴的package包/類
public UserType getGeometryUserType() {
	return new PGGeometryUserType();
}
 
開發者ID:gisgraphy,項目名稱:gisgraphy,代碼行數:4,代碼來源:PostgisDialectNG.java

示例15: getGeometryUserType

import org.hibernate.usertype.UserType; //導入依賴的package包/類
public UserType getGeometryUserType() {
    return new PGGeometryUserType();
}
 
開發者ID:gisgraphy,項目名稱:gisgraphy,代碼行數:4,代碼來源:PostgisDialectNG2.java


注:本文中的org.hibernate.usertype.UserType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。