Best code examples for Hibernate ORM AnnotationConfiguration class (org.hibernate.cfg.AnnotationConfiguration)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM AnnotationConfiguration class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Hibernate ORM AnnotationConfiguration examples from Open Source projects
This code example shows how to use the following methods: configure, buildSessionFactory
	/** 
	 * Getting a real Hibernate Session, from a memory database. 
	 */ 
	@Before 
	public void setUp() throws Exception {
		AnnotationConfiguration cfg = new AnnotationConfiguration();
		cfg.configure().setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:mydvdsDB");
		session = cfg.buildSessionFactory().openSession();
		session.beginTransaction(); 
		dao = new DefaultDvdDao(session);
	} 
 
 
	/** 
	 * Undoing all changes to database 
	 * @throws Exception 
	 */ 
	@After 
	public void tearDown() throws Exception {
		if (session != null && session.getTransaction().isActive()) { 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: configure, setProperties, buildSessionFactory, addFilterDefinition
            File testCfg = ResourceUtils.getFile("classpath:hibernate.cfg.xml");
            File mockFilter = ResourceUtils
                    .getFile("classpath:mock_filters.hbm.xml"); 
            Properties props = new Properties();
            props.load(new FileInputStream(local));
            AnnotationConfiguration cfg = new AnnotationConfiguration();
            cfg.addFilterDefinition(new FilterDefinition("securityFilter",
                    "1=1", new HashMap()));
            cfg.configure(testCfg);
            cfg.setProperties(props);
            sessionFactory = cfg.buildSessionFactory();
        } catch (Throwable ex) {
            log.error(ex.toString());
            throw new ExceptionInInitializerError(ex);
        } 
    } 
 
    public static Session getSession() throws HibernateException {
        return sessionFactory.openSession();
    } 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: configure, buildSessionFactory
	/** 
	 * Getting a real Hibernate Session, from a memory database. 
	 */ 
	@Before 
	public void setUp() throws Exception {
		AnnotationConfiguration cfg = new AnnotationConfiguration();
		cfg.configure().setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:mydvdsDB");
		session = cfg.buildSessionFactory().openSession();
		session.beginTransaction(); 
		dao = new DefaultUserDao(session);
	} 
 
 
	/** 
	 * Undoing all changes to database 
	 * @throws Exception 
	 */ 
	@After 
	public void tearDown() throws Exception {
		if (session != null && session.getTransaction().isActive()) { 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: addAnnotatedClass, buildSessionFactory
This code example shows how to use the following methods: addAnnotatedClass, setProperty, buildSessionFactory
		 
		new ExecuteContext(getOutputDir(), file, jars) {
			 
		   protected void execute() throws Exception {
			    
			   AnnotationConfiguration configuration = new AnnotationConfiguration();
				Class puppet = getUcl().loadClass( "org.hibernate.tool.hbm2x." + className );
				configuration.addAnnotatedClass( puppet );
				 
				configuration.setProperty( "hibernate.hbm2ddl.auto", "create-drop" );
				SessionFactory sf = configuration.buildSessionFactory();
				Session s = sf.openSession();
 
				Object puppetInst = puppet.newInstance();
				puppet.getMethod( "setName", new Class[]{String.class} ).invoke( puppetInst, new Object[]{"Barbie"} );
				 
				if(className.equals("Bungalow")) { // hack to avoid not-null execption
					puppet.getMethod("setMascot", new Class[] { puppet }).invoke( puppetInst, new Object[] { puppetInst } );
				} 
				 
Full Snippet Info
6
CodeRank
See Code Examples for Hibernate ORM AnnotationConfiguration Methods: