当前位置: 首页>>代码示例>>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;未经允许,请勿转载。