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 ); } }
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 ); } } }
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; } }
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 );
private static Dialect instantiateDialect(String dialectName) throws HibernateException { if ( dialectName == null ) { throw new HibernateException( "The dialect was not set. Set the property hibernate.dialect." ); } try { return (Dialect) ReflectHelper.classForName( dialectName ).newInstance(); } catch ( ClassNotFoundException cnfe ) { throw new HibernateException( "Dialect class not found: " + dialectName ); } catch ( Exception e ) { throw new HibernateException( "Could not instantiate given dialect class: " + dialectName, e ); } }
public static DatasourceConnectionProviderImpl buildDataSourceConnectionProvider(String dbName) { try { Class dataSourceClass = ReflectHelper.classForName( DATA_SOURCE, ConnectionProviderBuilder.class ); DataSource actualDataSource = (DataSource) dataSourceClass.newInstance(); ReflectHelper.findSetterMethod( dataSourceClass, "URL", String.class ).invoke(
/** * 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 + "]" ); } }
public boolean isInstance(Object object) { String resolvedEntityName = null; if ( Proxy.isProxyClass( object.getClass() ) ) { InvocationHandler handler = Proxy.getInvocationHandler( object ); if ( DataProxyHandler.class.isAssignableFrom( handler.getClass() ) ) { DataProxyHandler myHandler = ( DataProxyHandler ) handler; resolvedEntityName = myHandler.getEntityName(); } } try { return ReflectHelper.classForName( entityName ).isInstance( object ); } catch( Throwable t ) { throw new HibernateException( "could not get handle to entity-name as interface : " + t ); } // return entityName.equals( resolvedEntityName ); } }
@Override @SuppressWarnings("unchecked") public void setParameterValues(Properties parameters) { ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE ); if ( reader != null ) { setJavaTypeDescriptor( new SerializableTypeDescriptor<T>( reader.getReturnedClass() ) ); } else { String className = parameters.getProperty( CLASS_NAME ); if ( className == null ) { throw new MappingException( "No class name defined for type: " + SerializableToBlobType.class.getName() ); } try { setJavaTypeDescriptor( new SerializableTypeDescriptor<T>( ReflectHelper.classForName( className ) ) ); } catch ( ClassNotFoundException e ) { throw new MappingException( "Unable to load class from " + CLASS_NAME + " parameter", e ); } } } }
@Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { try { String stringValue = javaTypeDescriptor.unwrap( value, String.class, options ); Class clazz= ReflectHelper.classForName( "org.postgresql.util.PGobject", this.getClass()); Object holder = clazz.newInstance(); ReflectHelper.setterMethodOrNull( clazz, "type", String.class ).invoke( holder, "inet" ); ReflectHelper.setterMethodOrNull( clazz, "value", String.class ).invoke( holder, stringValue ); st.setObject( index, holder ); } catch (ClassNotFoundException|IllegalAccessException|InstantiationException|InvocationTargetException e) { throw new IllegalArgumentException( e ); } }
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; }
optimizerClass = ReflectHelper.classForName( type );
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(); } }
final String enumClassName = (String) parameters.get( ENUM ); try { enumClass = ReflectHelper.classForName( enumClassName, this.getClass() ).asSubclass( Enum.class );
final Class props = ReflectHelper.classForName( "org.hsqldb.persist.HsqlDatabaseProperties" ); final String versionString = (String) props.getDeclaredField( "THIS_VERSION" ).get( null );
final Class h2ConstantsClass = ReflectHelper.classForName( "org.h2.engine.Constants" ); final int majorVersion = (Integer) h2ConstantsClass.getDeclaredField( "VERSION_MAJOR" ).get( null ); final int minorVersion = (Integer) h2ConstantsClass.getDeclaredField( "VERSION_MINOR" ).get( null );
public Class getComponentClass() throws MappingException { try { return ReflectHelper.classForName(componentClassName); } catch (ClassNotFoundException cnfe) { throw new MappingException("component class not found: " + componentClassName, cnfe); } }
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 ); } }
public void setParameterValues(Properties parameters) { String enumClassName = parameters.getProperty("enumClassname"); try { enumClass = ReflectHelper.classForName(enumClassName); } catch (ClassNotFoundException cnfe) { throw new HibernateException("Enum class not found", cnfe); } }
public Class getProxyInterface() { if (proxyInterfaceName==null) return null; try { return ReflectHelper.classForName( proxyInterfaceName ); } catch (ClassNotFoundException cnfe) { throw new MappingException("proxy class not found: " + proxyInterfaceName, cnfe); } } public boolean useDynamicInsert() {