当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.addFile方法代码示例

本文整理汇总了Java中org.hibernate.cfg.Configuration.addFile方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.addFile方法的具体用法?Java Configuration.addFile怎么用?Java Configuration.addFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.cfg.Configuration的用法示例。


在下文中一共展示了Configuration.addFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getConfiguration

import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
private Configuration getConfiguration() throws Exception {
	Configuration cfg = new Configuration();
	if (namingStrategy!=null) {
		cfg.setNamingStrategy(
				(NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
			);
	}
	if (configurationFile != null) {
		cfg.configure( configurationFile );
	}

	String[] files = getFiles();
	for (int i = 0; i < files.length; i++) {
		String filename = files[i];
		if ( filename.endsWith(".jar") ) {
			cfg.addJar( new File(filename) );
		}
		else {
			cfg.addFile(filename);
		}
	}
	return cfg;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SchemaExportTask.java

示例2: getConfiguration

import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
private Configuration getConfiguration() throws Exception {
	Configuration cfg = new Configuration();
	if (namingStrategy!=null) {
		cfg.setNamingStrategy(
				(NamingStrategy) ReflectHelper.classForName( namingStrategy ).newInstance()
			);
	}
	if (configurationFile!=null) {
		cfg.configure( configurationFile );
	}

	String[] files = getFiles();
	for (int i = 0; i < files.length; i++) {
		String filename = files[i];
		if ( filename.endsWith(".jar") ) {
			cfg.addJar( new File(filename) );
		}
		else {
			cfg.addFile(filename);
		}
	}
	return cfg;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SchemaUpdateTask.java

示例3: getConfiguration

import org.hibernate.cfg.Configuration; //导入方法依赖的package包/类
private Configuration getConfiguration() throws Exception {
	Configuration cfg = new Configuration();
	if (namingStrategy!=null) {
		cfg.setNamingStrategy(
				(NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
			);
	}
	if (configurationFile!=null) {
		cfg.configure( configurationFile );
	}

	String[] files = getFiles();
	for (int i = 0; i < files.length; i++) {
		String filename = files[i];
		if ( filename.endsWith(".jar") ) {
			cfg.addJar( new File(filename) );
		}
		else {
			cfg.addFile(filename);
		}
	}
	return cfg;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SchemaValidatorTask.java

示例4: 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

示例5: 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.addFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。