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


Java AnnotationConfiguration类代码示例

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


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

示例1: ReloadConfig

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
public static void ReloadConfig() {
    try {
        AnnotationConfiguration config = new AnnotationConfiguration();
        Conexion conn = configDB.config();
         /*
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/zille2</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">infomati</property>*/
        config.setProperty("hibernate.connection.url", 
                "jdbc:mysql://" + conn.getHost() + ":3306/" + conn.getDbname());
        config.setProperty("hibernate.connection.username", conn.getDbuser());
        config.setProperty("hibernate.connection.password", conn.getDbpass());
        System.out.println("Reiniciando configuración hibernate");
        sessionFactory = config.configure().buildSessionFactory();
    } catch (Throwable ex) {
        // Log the exception. 
        System.err.println("Initial SessionFactory creation failed." + ex);
        throw new ExceptionInInitializerError(ex);
    }
}
 
开发者ID:infoINGenieria,项目名称:zprojects,代码行数:21,代码来源:HibernateUtil.java

示例2: postProcessMappings

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
/**
 * Reads metadata from annotated classes and packages into the
 * AnnotationConfiguration instance.
 */
@Override
protected void postProcessMappings(Configuration config) throws HibernateException {
	AnnotationConfiguration annConfig = (AnnotationConfiguration) config;
	if (this.annotatedClasses != null) {
		for (Class<?> annotatedClass : this.annotatedClasses) {
			annConfig.addAnnotatedClass(annotatedClass);
		}
	}
	if (this.annotatedPackages != null) {
		for (String annotatedPackage : this.annotatedPackages) {
			annConfig.addPackage(annotatedPackage);
		}
	}
	scanPackages(annConfig);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:AnnotationSessionFactoryBean.java

示例3: buildSessionFactory

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
private static SessionFactory buildSessionFactory() {
    try {
        // Create the SessionFactory from hibernate.cfg.xml
        return new AnnotationConfiguration().configure()
        		.addAnnotatedClass(AccountModel.class)
        		.addAnnotatedClass(RESTServiceModel.class)
        		.addAnnotatedClass(ResourceModel.class)
        		.addAnnotatedClass(RESTMethodModel.class)
        		.addAnnotatedClass(RESTParameterModel.class)
        		.addAnnotatedClass(InputMessageModel.class)
        		.addAnnotatedClass(InputParameterModel.class)
        		.addAnnotatedClass(OutputMessageModel.class)
        		.addAnnotatedClass(OutputParameterModel.class)
        		.addAnnotatedClass(SOAPOperationModel.class)
        		.addAnnotatedClass(SOAPServiceModel.class)
        		.buildSessionFactory();//TODO add the rest models here
    }
    catch (Throwable ex) {
        // Make sure you log the exception, as it might be swallowed
        System.err.println("Initial SessionFactory creation failed." + ex);
        throw new ExceptionInInitializerError(ex);
    }
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:24,代码来源:HibernateUtil.java

示例4: getSession

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
public static Session getSession()
{
	if (sessionFactory == null)
	{
		synchronized (HibernateManager.class)
		{
			if (sessionFactory == null)
			{
				try
				{
					log.info("Creating new Content SessionFactory");
					sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
					
				}
				catch (Throwable ex)
				{
					log.error("Initial Content SessionFactory creation failed.", ex);
					throw new ExceptionInInitializerError(ex);
				}
			}
		}
	}
	return sessionFactory.openSession();
}
 
开发者ID:snavruzov,项目名称:Expert_system,代码行数:25,代码来源:HibernateManager.java

示例5: testAnnotated

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
public void testAnnotated(){
	SessionFactory sf=null;
	AnnotationConfiguration configuration= null;
	String hibernateCfgFileName = "instanceleveltest_annotations.hibernate.cfg.xml";
	
	configuration = new AnnotationConfiguration().configure(hibernateCfgFileName);
	sf = configuration.buildSessionFactory();
	
	

	Session session = null;
	session = sf.openSession();
	Criteria criteria = session.createCriteria(Card.class);
	List l = criteria.list();
	int size = l.size();
	System.out.println("============= Annotated SYSTEM ==================");
	System.out.println("Total no of Cards on which user has access= "+l.size());
	System.out.println("------------------------------------------------------");
	session.close();
	sf.close();
	
	assertEquals("Incorrect number of cards retrieved",size, 53); // Expecting all cards in the deck including the joker.
}
 
开发者ID:NCIP,项目名称:common-security-module,代码行数:24,代码来源:HibernateAnnotationsTest.java

示例6: main

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
/**
	 * @param args
	 */
	public static void main(String[] args) {
		// Configuration config = new AnnotationConfiguration().configure();

		AnnotationConfiguration config = new AnnotationConfiguration().configure();
		config.addAnnotatedClass(TUser.class)
				.addAnnotatedClass(TGameDetailRecord.class)
				.addAnnotatedClass(TMatch.class)
				.addAnnotatedClass(TMatchType.class)
				.addAnnotatedClass(TResult.class);
		
/*
		config.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
		new SchemaExport(cfg, connection);*/
		
		SchemaExport se = new SchemaExport(config);
		se.create(true, true);
	}
 
开发者ID:linzi-zero,项目名称:billiards,代码行数:21,代码来源:MakeTable.java

示例7: HibernateHelper

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
/**
     * Constructor to build the hibernate helper.
     * @param namingStrategy the name strategy, if one is needed, null otherwise.
     * @param interceptor the interceptor, if one is needed, null otherwise.
     */
    public HibernateHelper(NamingStrategy namingStrategy, Interceptor interceptor) {
        try {
            configuration = new AnnotationConfiguration();
            initializeConfig(namingStrategy, interceptor);
            configuration = configuration.configure();
            // We call buildSessionFactory twice, because it appears that the annotated classes are
            // not 'activated' in the config until we build. The filters required the classes to
            // be present, so we throw away the first factory and use the second. If this is
            // removed, you'll likely see a NoClassDefFoundError in the unit tests
            configuration.buildSessionFactory();
            sessionFactory = configuration.buildSessionFactory();
        } catch (HibernateException e) {
//            LOG.error(e.getMessage(), e);
//            throw new ExceptionInInitializerError(e);
            LOG.warn("Failed to initialize HibernateHelper using hibernate.cfg.xml.  "
                    + "This is expected behavior during unit testing." , e);
            e.printStackTrace();
        }
    }
 
开发者ID:NCIP,项目名称:labviewer,代码行数:25,代码来源:HibernateHelper.java

示例8: setUp

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
public static void setUp() {		
	AnnotationConfiguration config = new AnnotationConfiguration();
	config.setProperty("hibernate.current_session_context_class", "managed");
	config.setProperty("hibernate.c3p0.max_size", "20").setProperty(
			"hibernate.c3p0.timeout", "3000").setProperty(
			"hibernate.c3p0.idle_test_period", "300").setProperty("hibernate.hbm2ddl.auto", "update");

	ConstellioAnnotationUtils.addAnnotatedClasses(config);
	
	sessionFactory = config.buildSessionFactory();

	Application.set(new DataDummyWebApplication());
	
	org.hibernate.classic.Session hibernateSession = sessionFactory.openSession();
	hibernateSession.beginTransaction();
	ManagedSessionContext.bind(hibernateSession);
}
 
开发者ID:BassJel,项目名称:Jouve-Project,代码行数:18,代码来源:EntityManagerUtils.java

示例9: testarConexao1

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
private  void testarConexao1(){
    
        new Thread(){
        @Override
        public void run(){
        Session session= null;
        try{
        
        progress.setString("Testando Conexão com o Banco de Dados");
        session = new AnnotationConfiguration().configure().setProperty("hibernate.connection.username", "root").setProperty("hibernate.connection.password", "123").buildSessionFactory().openSession();
       
    }catch(HibernateException e){
        
        JOptionPane.showMessageDialog(null, "Erro de conexão ao banco de dados: "+e.getMessage());
        System.exit(1);
    }finally{
        if(session != null){
            session.close();
        }  
    }
      
        progress.setString("Conexão bem sucedida...");
        }     
    }.start();    
}
 
开发者ID:AlexandrebQueiroz,项目名称:acal,代码行数:26,代码来源:Splash.java

示例10: pre

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
@BeforeClass
public final void pre() {
    injector = Guice.createInjector(PersistenceService.usingHibernate()
        .across(UnitOfWork.TRANSACTION)
        .addAccessor(AbstractWithDF.class)
        .forAll(Matchers.any())

        .buildModule(),

            new AbstractModule() {

                protected void configure() {
                    bind(Configuration.class).toInstance(new AnnotationConfiguration()
                        .addAnnotatedClass(HibernateTestEntity.class)
                        .setProperties(Initializer.loadProperties("spt-persistence.properties")));

                }
            });

    injector.getInstance(PersistenceService.class).start();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:22,代码来源:HibernateAbstractClassDFTest.java

示例11: pre

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
@BeforeMethod
public void pre() {
    injector = Guice.createInjector(PersistenceService.usingHibernate()
            .across(UnitOfWork.TRANSACTION)
            .addAccessor(AbstractDF.class)
            .buildModule(),

            new AbstractModule() {

                protected void configure() {
                    bind(Configuration.class).toInstance(new AnnotationConfiguration()
                        .addAnnotatedClass(HibernateTestEntityTxnal.class)
                        .setProperties(Initializer.loadProperties("spt-persistence.properties")));
                }
            });

    injector.getInstance(PersistenceService.class).start();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:19,代码来源:HibernateDynamicFinderAbstractClassTest.java

示例12: pre

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
@BeforeClass
public void pre() {
    injector = Guice.createInjector(PersistenceService.usingHibernate()
            .across(UnitOfWork.TRANSACTION)
            .addAccessor(HibernateTestAccessor.class)
            .buildModule(),

            new AbstractModule() {

                protected void configure() {
                    bind(Configuration.class).toInstance(new AnnotationConfiguration()
                        .addAnnotatedClass(HibernateTestEntity.class)
                        .setProperties(Initializer.loadProperties("spt-persistence.properties")));
                }
            });

    injector.getInstance(PersistenceService.class).start();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:19,代码来源:HibernateDynamicFindersTest.java

示例13: pre

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
@BeforeMethod
public void pre() {
    injector = Guice.createInjector(PersistenceService.usingHibernate()
            .across(UnitOfWork.TRANSACTION)
            .addAccessor(HibernateTestAccessorForDFs.class)
            .buildModule(),

            new AbstractModule() {

                protected void configure() {
                    bind(Configuration.class).toInstance(new AnnotationConfiguration()
                        .addAnnotatedClass(HibernateTestEntityTxnal.class)
                        .setProperties(Initializer.loadProperties("spt-persistence.properties")));
                }
            });

    injector.getInstance(PersistenceService.class).start();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:19,代码来源:HibernateDynamicFinderWithIsolationTest.java

示例14: pre

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
@BeforeMethod
public void pre() {
    injector = Guice.createInjector(PersistenceService.usingHibernate()
        .across(UnitOfWork.TRANSACTION)
        .forAll(Matchers.annotatedWith(Transactional.class), Matchers.any())
        .buildModule(),
            new AbstractModule() {

                protected void configure() {
                    bind(Configuration.class).toInstance(new AnnotationConfiguration()
                        .addAnnotatedClass(HibernateTestEntity.class)
                        .setProperties(Initializer.loadProperties("spt-persistence.properties")));
                }
            }
    );

    //startup persistence
    injector.getInstance(PersistenceService.class)
            .start();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:21,代码来源:ClassLevelManagedLocalTransactionsTest.java

示例15: pre

import org.hibernate.cfg.AnnotationConfiguration; //导入依赖的package包/类
@BeforeClass
public void pre() {
    injector = Guice.createInjector(PersistenceService.usingHibernate()
        .across(UnitOfWork.REQUEST)
        .forAll(Matchers.subclassesOf(TransactionalObject.class), Matchers.any())
        .buildModule(),
            new AbstractModule() {

                protected void configure() {
                    bind(Configuration.class).toInstance(new AnnotationConfiguration()
                        .addAnnotatedClass(HibernateTestEntity.class)
                        .setProperties(Initializer.loadProperties("spr-managed-persistence.properties")));
                }
            });

    //startup persistence
    injector.getInstance(PersistenceService.class)
            .start();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:20,代码来源:ManualLocalTransactionsWithCustomMatchersTest.java


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