Java Code Examples for org.hibernate.internal.util.ReflectHelper#classForName()
The following examples show how to use
org.hibernate.internal.util.ReflectHelper#classForName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OracleTypesHelper.java From lams with GNU General Public License v2.0 | 6 votes |
private Class locateOracleTypesClass() { try { return ReflectHelper.classForName( ORACLE_TYPES_CLASS_NAME ); } catch (ClassNotFoundException e) { try { return ReflectHelper.classForName( DEPRECATED_ORACLE_TYPES_CLASS_NAME ); } catch (ClassNotFoundException e2) { throw new HibernateException( String.format( "Unable to locate OracleTypes class using either known FQN [%s, %s]", ORACLE_TYPES_CLASS_NAME, DEPRECATED_ORACLE_TYPES_CLASS_NAME ), e ); } } }
Example 2
Source File: TypeFactory.java From lams with GNU General Public License v2.0 | 6 votes |
public CollectionType customCollection( String typeName, Properties typeParameters, String role, String propertyRef) { Class typeClass; try { typeClass = ReflectHelper.classForName( typeName ); } catch (ClassNotFoundException cnfe) { throw new MappingException( "user collection type class not found: " + typeName, cnfe ); } CustomCollectionType result = new CustomCollectionType( typeScope, typeClass, role, propertyRef ); if ( typeParameters != null ) { injectParameters( result.getUserType(), typeParameters ); } return result; }
Example 3
Source File: EntityTuplizerFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Construct an instance of the given tuplizer class. * * @param tuplizerClassName The name of the tuplizer class to instantiate * @param metamodel The metadata for the entity. * @param persistentClass The mapping info for the entity. * * @return The instantiated tuplizer * * @throws HibernateException If class name cannot be resolved to a class reference, or if the * {@link Constructor#newInstance} call fails. */ @SuppressWarnings({ "unchecked" }) public EntityTuplizer constructTuplizer( String tuplizerClassName, EntityMetamodel metamodel, PersistentClass persistentClass) { try { Class<? extends EntityTuplizer> tuplizerClass = ReflectHelper.classForName( tuplizerClassName ); return constructTuplizer( tuplizerClass, metamodel, persistentClass ); } catch ( ClassNotFoundException e ) { throw new HibernateException( "Could not locate specified tuplizer class [" + tuplizerClassName + "]" ); } }
Example 4
Source File: SQLExceptionConverterFactory.java From lams with GNU General Public License v2.0 | 5 votes |
private static SQLExceptionConverter constructConverter(String converterClassName, ViolatedConstraintNameExtracter violatedConstraintNameExtracter) { try { LOG.tracev( "Attempting to construct instance of specified SQLExceptionConverter [{0}]", converterClassName ); final Class converterClass = ReflectHelper.classForName( converterClassName ); // First, try to find a matching constructor accepting a ViolatedConstraintNameExtracter param... final Constructor[] ctors = converterClass.getDeclaredConstructors(); for ( Constructor ctor : ctors ) { if ( ctor.getParameterTypes() != null && ctor.getParameterCount() == 1 ) { if ( ViolatedConstraintNameExtracter.class.isAssignableFrom( ctor.getParameterTypes()[0] ) ) { try { return (SQLExceptionConverter) ctor.newInstance( violatedConstraintNameExtracter ); } catch (Throwable ignore) { // eat it and try next } } } } // Otherwise, try to use the no-arg constructor return (SQLExceptionConverter) converterClass.newInstance(); } catch (Throwable t) { LOG.unableToConstructSqlExceptionConverter( t ); } return null; }
Example 5
Source File: DerbyDialect.java From lams with GNU General Public License v2.0 | 5 votes |
private void determineDriverVersion() { try { // locate the derby sysinfo class and query its version info final Class sysinfoClass = ReflectHelper.classForName( "org.apache.derby.tools.sysinfo", this.getClass() ); final Method majorVersionGetter = sysinfoClass.getMethod( "getMajorVersion", ReflectHelper.NO_PARAM_SIGNATURE ); final Method minorVersionGetter = sysinfoClass.getMethod( "getMinorVersion", ReflectHelper.NO_PARAM_SIGNATURE ); driverVersionMajor = (Integer) majorVersionGetter.invoke( null, ReflectHelper.NO_PARAMS ); driverVersionMinor = (Integer) minorVersionGetter.invoke( null, ReflectHelper.NO_PARAMS ); } catch ( Exception e ) { LOG.unableToLoadDerbyDriver( e.getMessage() ); driverVersionMajor = -1; driverVersionMinor = -1; } }
Example 6
Source File: ClassTypeDescriptor.java From lams with GNU General Public License v2.0 | 5 votes |
public Class fromString(String string) { if ( string == null ) { return null; } try { return ReflectHelper.classForName( string ); } catch ( ClassNotFoundException e ) { throw new HibernateException( "Unable to locate named class " + string ); } }
Example 7
Source File: EntityType.java From lams with GNU General Public License v2.0 | 5 votes |
private Class determineAssociatedEntityClass() { final String entityName = getAssociatedEntityName(); try { return ReflectHelper.classForName( entityName ); } catch (ClassNotFoundException cnfe) { return this.scope.getTypeConfiguration().getSessionFactory().getMetamodel().entityPersister( entityName ). getEntityTuplizer().getMappedClass(); } }
Example 8
Source File: JSONType.java From spring-data-jpa-extra with Apache License 2.0 | 5 votes |
@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); } } }