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


Java Configuration.setProperties方法代碼示例

本文整理匯總了Java中org.hibernate.cfg.Configuration.setProperties方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.setProperties方法的具體用法?Java Configuration.setProperties怎麽用?Java Configuration.setProperties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.cfg.Configuration的用法示例。


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

示例1: getSchemaUpdate

import org.hibernate.cfg.Configuration; //導入方法依賴的package包/類
private SchemaUpdate getSchemaUpdate(Configuration cfg) throws HibernateException, IOException {
	Properties properties = new Properties();
	properties.putAll( cfg.getProperties() );
	if (propertiesFile == null) {
		properties.putAll( getProject().getProperties() );
	}
	else {
		properties.load( new FileInputStream(propertiesFile) );
	}
	cfg.setProperties(properties);
	SchemaUpdate su = new SchemaUpdate(cfg);
	su.setOutputFile( outputFile.getPath() );
	su.setDelimiter(delimiter);
	su.setHaltOnError(haltOnError);
	return su;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:SchemaUpdateTask.java

示例2: getSchemaExport

import org.hibernate.cfg.Configuration; //導入方法依賴的package包/類
private SchemaExport getSchemaExport(Configuration cfg) throws HibernateException, IOException {
	Properties properties = new Properties();
	properties.putAll( cfg.getProperties() );
	if (propertiesFile == null) {
		properties.putAll( getProject().getProperties() );
	}
	else {
		properties.load( new FileInputStream(propertiesFile) );
	}
	cfg.setProperties(properties);
	return new SchemaExport(cfg)
			.setHaltOnError(haltOnError)
			.setOutputFile( outputFile.getPath() )
			.setDelimiter(delimiter);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:16,代碼來源:SchemaExportTask.java

示例3: getSchemaValidator

import org.hibernate.cfg.Configuration; //導入方法依賴的package包/類
private SchemaValidator getSchemaValidator(Configuration cfg) throws HibernateException, IOException {
	Properties properties = new Properties();
	properties.putAll( cfg.getProperties() );
	if (propertiesFile == null) {
		properties.putAll( getProject().getProperties() );
	}
	else {
		properties.load( new FileInputStream(propertiesFile) );
	}
	cfg.setProperties(properties);
	return new SchemaValidator(cfg);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:SchemaValidatorTask.java

示例4: newSessionFactory

import org.hibernate.cfg.Configuration; //導入方法依賴的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);
    }
    configuration.setProperties(properties);
    return configuration.buildSessionFactory(
            new BootstrapServiceRegistryBuilder()
                    .build()
    );
}
 
開發者ID:vladmihalcea,項目名稱:hibernate-types,代碼行數:29,代碼來源:AbstractTest.java

示例5: main

import org.hibernate.cfg.Configuration; //導入方法依賴的package包/類
public static void main(String[] args) {
	try {
		Configuration cfg = new Configuration();

		boolean script = true;
		// If true then execute db updates, otherwise just generate and display updates
		boolean doUpdate = true;
		String propFile = null;

		for ( int i = 0; i < args.length; i++ ) {
			if ( args[i].startsWith( "--" ) ) {
				if ( args[i].equals( "--quiet" ) ) {
					script = false;
				}
				else if ( args[i].startsWith( "--properties=" ) ) {
					propFile = args[i].substring( 13 );
				}
				else if ( args[i].startsWith( "--config=" ) ) {
					cfg.configure( args[i].substring( 9 ) );
				}
				else if ( args[i].startsWith( "--text" ) ) {
					doUpdate = false;
				}
				else if ( args[i].startsWith( "--naming=" ) ) {
					cfg.setNamingStrategy(
							( NamingStrategy ) ReflectHelper.classForName( args[i].substring( 9 ) ).newInstance()
					);
				}
			}
			else {
				cfg.addFile( args[i] );
			}

		}

		if ( propFile != null ) {
			Properties props = new Properties();
			props.putAll( cfg.getProperties() );
			props.load( new FileInputStream( propFile ) );
			cfg.setProperties( props );
		}

		StandardServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
		try {
			new SchemaUpdate( serviceRegistry, cfg ).execute( script, doUpdate );
		}
		finally {
			serviceRegistry.destroy();
		}
	}
	catch ( Exception e ) {
           LOG.unableToRunSchemaUpdate(e);
		e.printStackTrace();
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:56,代碼來源:SchemaUpdate.java

示例6: main

import org.hibernate.cfg.Configuration; //導入方法依賴的package包/類
public static void main(String[] args) {
	try {
		Configuration cfg = new Configuration();

		String propFile = null;

		for ( int i = 0; i < args.length; i++ ) {
			if ( args[i].startsWith( "--" ) ) {
				if ( args[i].startsWith( "--properties=" ) ) {
					propFile = args[i].substring( 13 );
				}
				else if ( args[i].startsWith( "--config=" ) ) {
					cfg.configure( args[i].substring( 9 ) );
				}
				else if ( args[i].startsWith( "--naming=" ) ) {
					cfg.setNamingStrategy(
							( NamingStrategy ) ReflectHelper.classForName( args[i].substring( 9 ) ).newInstance()
					);
				}
			}
			else {
				cfg.addFile( args[i] );
			}

		}

		if ( propFile != null ) {
			Properties props = new Properties();
			props.putAll( cfg.getProperties() );
			props.load( new FileInputStream( propFile ) );
			cfg.setProperties( props );
		}

		StandardServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
		try {
			new SchemaValidator( serviceRegistry, cfg ).validate();
		}
		finally {
			serviceRegistry.destroy();
		}
	}
	catch ( Exception e ) {
           LOG.unableToRunSchemaUpdate(e);
		e.printStackTrace();
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:47,代碼來源:SchemaValidator.java


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