AnnotationConfiguration setProperties - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AnnotationConfiguration setProperties method.

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();
    } 
7
CodeRank
This code example shows how to use the following methods:addAnnotatedClass, setProperties
 
    protected Session session;
    protected Transaction transaction;
 
    private Configuration getConfiguration() {
        AnnotationConfiguration config = new AnnotationConfiguration();
 
        Properties properties = new Properties();
        properties.putAll(getDefaultProperties());
        properties.putAll(getConfigProperties());
 
        config.setProperties(properties);
        config.addAnnotatedClass(Contact.class);
 
 
        return config;
    } 
 
    private Properties getDefaultProperties() {
        Properties props = new Properties();
4
CodeRank
setProperties Method Overview
Specify a completely new set of properties
See Code Examples for other Hibernate ORM AnnotationConfiguration Methods: