• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Configuration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getConfiguration

import net.sf.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( new File(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:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:SchemaExportTask.java


示例2: open

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
/**
 * Specify the underlying <tt>SessionFactory</tt>, by passing a JNDI name.
 * The <tt>accessMode</tt> is ignored by Hibernate.
 * @see org.odmg.Database#open(String, int)
 */
public void open(String name, int accessMode) throws ODMGException {
	try {
		new Configuration().configure();
	}
	catch (HibernateException he) {
		throw new ODMGException( he.getMessage() );
	}
	sessionFactory = (SessionFactory) SessionFactoryObjectFactory.getNamedInstance(name);
	if (sessionFactory==null) throw new ODMGException("No SessionFactory was associated with the given JDNI name");
	/*try {
		sessionFactory = (SessionFactory) NamingHelper.getInitialContext( Environment.getProperties() ).lookup(name);
	}
	catch (NamingException ne) {
		throw new ODMGException( ne.getMessage() );
	}*/
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:Database.java


示例3: hibernateInit

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
@Ignore
@Test
public void hibernateInit() throws Exception
{
    Database.init();

    Configuration config = new Configuration();
    config.configure("hibernate.cfg.xml");
    SessionFactory sessionFactory = config.buildSessionFactory();
    Session session = sessionFactory.openSession();
    Transaction transaction = session.beginTransaction();

    // Filter-time code (H3SessionAjaxFilter)
    transaction.commit();

    // Shutdown code, when do we need to do this?
    sessionFactory.close();
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:19,代码来源:HibernateConverterTest.java


示例4: PersonalBlogService

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
/**
 * Constructor for PersonalBlogService.
 */
protected PersonalBlogService(Properties conn)
    throws InitializationException {
    log.debug("initialization - constructor");

    try {
        cfg = new Configuration().addClass(Post.class)
                                 .addClass(Comment.class)
                                 .addClass(Referrer.class)
                                 .addClass(BlogProperty.class);

        if (conn != null) {
            cfg.setProperties(conn);
            pm = new PropertyManager(conn);
        } else {
            pm = new PropertyManager();
        }

        //I want to take it out of here, for these
        sf = cfg.buildSessionFactory();
    } catch (Exception e) {
        log.error("Error initializing PersonalBlog Service", e);

        throw new InitializationException(e);
    }
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:29,代码来源:PersonalBlogService.java


示例5: initSessionFactory

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
private static SessionFactory initSessionFactory(String fileName){
	SessionFactory sf = null;
	try{
		/**
		 * We will use this commented out the style for creating sessionfactory
		 */
		//URL url =  ClassLoader.getSystemResource(fileName);
		//String file_name = url.getFile();
	    //File f = new File(file_name);
     //File f = new File("config/myfile.cfg.xml");
	 
	 //sf = new Configuration().configure(f).buildSessionFactory();
		sf = new Configuration().configure().buildSessionFactory();
		 if(sf!=null){
		 	System.out.println("Message from ApplicationSessionFactory: Got Session !");
		 }else{
		 	System.out.println("Message from ApplicationSessionFactory: could not get Session !");
		 }
	}catch(Exception ex){
		ex.printStackTrace();
	}
	return sf;
}
 
开发者ID:NCIP,项目名称:common-security-module,代码行数:24,代码来源:ApplicationSessionFactory.java


示例6: initSessionFactory

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
private static SessionFactory initSessionFactory(String fileName){
	SessionFactory sf = null;
	try{
		/**
		 * We will use this commented out the style for creating sessionfactory
		 */
	 File f = new File(fileName);
     //File f = new File("config/myfile.cfg.xml");
	 
	 sf = new Configuration().configure(f).buildSessionFactory();
		//sf = new Configuration().configure().buildSessionFactory();
		 
	}catch(Exception ex){
		ex.printStackTrace();
	}
	return sf;
}
 
开发者ID:NCIP,项目名称:common-security-module,代码行数:18,代码来源:LoggingSessionFactory.java


示例7: initSessionFactory

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
private static SessionFactory initSessionFactory(String fileName){
	SessionFactory sf = null;
	try{
		/**
		 * We will use this commented out the style for creating sessionfactory
		 */
		
	 File f = new File(fileName);
     //File f = new File("config/myfile.cfg.xml");
	 
	 sf = new Configuration().configure(f).buildSessionFactory();
		//sf = new Configuration().configure().buildSessionFactory();
		 
	}catch(Exception ex){
		ex.printStackTrace();
	}
	return sf;
}
 
开发者ID:NCIP,项目名称:common-security-module,代码行数:19,代码来源:ApplicationSessionFactory.java


示例8: createCollectionPersister

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
public static CollectionPersister createCollectionPersister(Configuration cfg, Collection model, SessionFactoryImplementor factory) throws HibernateException {
	Class persisterClass = model.getCollectionPersisterClass();
	if(persisterClass==null) { // default behavior
		return model.isOneToMany() ?
			(CollectionPersister) new OneToManyPersister(model, cfg, factory) :
			(CollectionPersister) new BasicCollectionPersister(model, cfg, factory);	
	} 
	else {
		return create(persisterClass, cfg, model, factory);
	}
	
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:13,代码来源:PersisterFactory.java


示例9: getSchemaExport

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
private SchemaExport getSchemaExport(Configuration cfg) throws HibernateException, IOException {
	SchemaExport schemaExport;
	if (propertiesFile == null) {
		schemaExport = new SchemaExport(cfg);
	} 
	else {
		Properties properties = new Properties();
		properties.load( new FileInputStream(propertiesFile) );
		schemaExport = new SchemaExport(cfg, properties);
	}
	schemaExport.setOutputFile(outputFile);
	schemaExport.setDelimiter(delimiter);
	return schemaExport;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:SchemaExportTask.java


示例10: SchemaExport

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
/**
 * Create a schema exporter for the given Configuration, with the given
 * database connection properties.
 */
public SchemaExport(Configuration cfg, Properties connectionProperties) throws HibernateException {
	this.connectionProperties = connectionProperties;
	dialect = Dialect.getDialect(connectionProperties);
	dropSQL = cfg.generateDropSchemaScript(dialect);
	createSQL = cfg.generateSchemaCreationScript(dialect);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:11,代码来源:SchemaExport.java


示例11: getConfiguration

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
private Configuration getConfiguration() throws HibernateException {
	Configuration cfg = new Configuration().addProperties( getProperties() );
	String[] mappingFiles = parseResourceList( getMapResources() );
	for ( int i=0; i<mappingFiles.length; i++ ) {
		cfg.addResource( mappingFiles[i], Thread.currentThread().getContextClassLoader() );
	}
	return cfg;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:9,代码来源:HibernateService.java


示例12: OneToManyPersister

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
public OneToManyPersister(
	Collection collection,
	Configuration cfg,
	SessionFactoryImplementor factory)
	throws MappingException, CacheException {
	super(collection, cfg, factory);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:8,代码来源:OneToManyPersister.java


示例13: main

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	
	final Main test = new Main();
	
	Configuration cfg = new Configuration()
		.addClass(AuctionItem.class)
		.addClass(Bid.class)
		.addClass(User.class)
		.setProperty(Environment.HBM2DDL_AUTO, "create");
	//cfg.setProperty("hibernate.show_sql", "true");
	
	test.factory = cfg.buildSessionFactory();
	
	test.createTestAuctions();
	test.viewAllAuctionsSlow();

	test.viewAllAuctionsFast();
	test.bidOnAuction(mainBidder, mainItem, 5.5f);
	test.viewAllAuctionsFast();
	
	test.viewUserAuctions( mainSeller.getId() );
	mainSeller.setEmail("[email protected]");
	test.changeUserDetails(mainSeller);
	test.changeItemDescription(mainItem.getId(), "new description");
	test.viewUserAuctions( mainSeller.getId() );
	
	test.viewAuctionsByDescription("It", 0);
	test.viewAuctionsByDescription("DESC", 3);
	test.viewAuctionsByDescription("DESC", 8);
	
	test.factory.close();
	
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:34,代码来源:Main.java


示例14: main

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws HibernateException , IOException, Exception
	{
		boolean isToPrintOnConsole = false;
		boolean isToExecuteOnDB = false;
		if(args.length!=0)
		{
			String arg = args[0];
			if(arg.equalsIgnoreCase("true"))
			{
				isToPrintOnConsole = true;
				isToExecuteOnDB = true;
			}
			if(arg.equalsIgnoreCase("false"))
			{
				isToPrintOnConsole = false;
				isToExecuteOnDB = false;
			}
		}
		
		File file = new File("db.properties");
		BufferedInputStream stram = new BufferedInputStream(new FileInputStream(file));  
		Properties p = new Properties();
		p.load(stram);
		stram.close();
		
		
			
		Configuration cfg = new Configuration();
		cfg.setProperties(p);
		cfg.addDirectory(new File("./WEB-INF/src"));
		new SchemaExport(cfg).setOutputFile("catissuecore.sql").create(isToPrintOnConsole, isToExecuteOnDB);
//		if(isToExecuteOnDB)
//			new GenerateUser();
	}
 
开发者ID:NCIP,项目名称:wustl-common-package,代码行数:35,代码来源:GenerateSchema.java


示例15: main

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
public static void main(String[] args) {
	try {
		Configuration cfg = new Configuration();
		
		boolean script = true;
		boolean drop = false;
		boolean export = true;
		String outFile = null;
		String propFile = null;
		boolean formatSQL = false;
		String delim = null;
		
		for ( int i=0; i<args.length; i++ )  {
			if( args[i].startsWith("--") ) {
				if( args[i].equals("--quiet") ) {
					script = false;
				}
				else if( args[i].equals("--drop") ) {
					drop = true;
				}
				else if( args[i].equals("--text") ) {
					export = false;
				}
				else if( args[i].startsWith("--output=") ) {
					outFile = args[i].substring(9);
				}
				else if( args[i].startsWith("--properties=") ) {
					propFile = args[i].substring(13);
				}
				else if( args[i].equals("--format") ) {
					formatSQL = true;
				}
				else if ( args[i].startsWith("--delimiter=") ) {
					delim = args[i].substring(12);
				}
				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 {
				String filename = args[i];
				if ( filename.endsWith( ".jar" ) ) {
					cfg.addJar(filename);
				}
				else {
					cfg.addFile(filename);
				}
			}
			
		}
		if(propFile!=null) {
			Properties props = new Properties();
			props.load( new FileInputStream(propFile) );
			new SchemaExport(cfg, props)
				.setOutputFile(outFile)
				.setDelimiter(delim)
				.execute(script, export, drop, formatSQL);
		}
		else {
			new SchemaExport(cfg)
				.setOutputFile(outFile)
				.setDelimiter(delim)
				.execute(script, export, drop, formatSQL);
		}
	}
	catch(Exception e) {
		log.error( "Error creating schema ", e );
		e.printStackTrace();
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:76,代码来源:SchemaExport.java


示例16: BasicCollectionPersister

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
public BasicCollectionPersister(Collection collection, Configuration cfg, SessionFactoryImplementor factory) 
	throws MappingException, CacheException {
	super(collection, cfg, factory);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:5,代码来源:BasicCollectionPersister.java


示例17: initHibernateMetaData

import net.sf.hibernate.cfg.Configuration; //导入依赖的package包/类
public static void initHibernateMetaData(Configuration configuration)
	{
		cfg = configuration;
//		This function finds all the relations and keeps in mappings set.
		findRelations();		
	}
 
开发者ID:NCIP,项目名称:wustl-common-package,代码行数:7,代码来源:HibernateMetaData.java



注:本文中的net.sf.hibernate.cfg.Configuration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CacheManager类代码示例发布时间:2022-05-22
下一篇:
Java FilterDefinition类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap