Example usage for org.hibernate.cfg Configuration addResource

List of usage examples for org.hibernate.cfg Configuration addResource

Introduction

In this page you can find the example usage for org.hibernate.cfg Configuration addResource.

Prototype

@Deprecated
public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException 

Source Link

Usage

From source file:com.globalsight.ling.tm3.integration.GSDataFactory.java

License:Apache License

@Override
public Configuration extendConfiguration(Configuration cfg) {
    // Initialize the GlobalSightLocale mapping so this works with
    // tm3tool/* w ww .jav a2  s  . c  o m*/
    return cfg
            .addResource("com/globalsight/persistence/hibernate/xml/GlobalSightLocale.hbm.xml",
                    getClass().getClassLoader())
            .addResource("com/globalsight/persistence/hibernate/xml/ProjectTM.hbm.xml",
                    getClass().getClassLoader())
            .addResource("com/globalsight/persistence/hibernate/xml/TranslationMemoryProfile.hbm.xml",
                    getClass().getClassLoader())
            .addResource("com/globalsight/persistence/hibernate/xml/LeverageProjectTM.hbm.xml",
                    getClass().getClassLoader())
            .addResource("com/globalsight/persistence/hibernate/xml/TDATM.hbm.xml", getClass().getClassLoader())
            .addResource("com/globalsight/persistence/hibernate/xml/Company.hbm.xml",
                    getClass().getClassLoader());
}

From source file:edu.northwestern.bioinformatics.studycalendar.security.csm.internal.DefaultCsmAuthorizationManagerFactory.java

License:BSD License

private SessionFactory createCsmSessionFactory() throws Exception {
    Configuration hibConf = new DefaultCsmHibernateConfiguration();

    // these paths are copied straight from CSM's ApplicationSessionFactory
    String[] mappingPaths = {/*  ww  w.  ja v  a2s .c om*/
            "gov/nih/nci/security/authorization/domainobjects/InstanceLevelMappingElement.hbm.xml",
            "gov/nih/nci/security/authorization/domainobjects/Privilege.hbm.xml",
            "gov/nih/nci/security/authorization/domainobjects/Application.hbm.xml",
            "gov/nih/nci/security/authorization/domainobjects/FilterClause.hbm.xml",
            "gov/nih/nci/security/authorization/domainobjects/Role.hbm.xml",
            "gov/nih/nci/security/dao/hibernate/RolePrivilege.hbm.xml",
            "gov/nih/nci/security/dao/hibernate/UserGroup.hbm.xml",
            "gov/nih/nci/security/dao/hibernate/ProtectionGroupProtectionElement.hbm.xml",
            "gov/nih/nci/security/authorization/domainobjects/Group.hbm.xml",
            "gov/nih/nci/security/authorization/domainobjects/User.hbm.xml",
            "gov/nih/nci/security/authorization/domainobjects/ProtectionGroup.hbm.xml",
            "gov/nih/nci/security/authorization/domainobjects/ProtectionElement.hbm.xml",
            "gov/nih/nci/security/authorization/domainobjects/UserGroupRoleProtectionGroup.hbm.xml",
            "gov/nih/nci/security/authorization/domainobjects/UserProtectionElement.hbm.xml" };
    for (String mappingPath : mappingPaths) {
        hibConf.addResource(mappingPath, AuthorizationManager.class.getClassLoader());
    }

    ClassLoader originalContextCL = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
        // this cast is endorsed by the Hibernate 3.6 Core docs as one of the two mechanisms to
        // add an entity name resolver.
        SessionFactoryImpl sessionFactory = (SessionFactoryImpl) hibConf.buildSessionFactory();
        sessionFactory.registerEntityNameResolver(new CglibProxyEntityNameResolver(), EntityMode.POJO);
        return sessionFactory;
    } finally {
        Thread.currentThread().setContextClassLoader(originalContextCL);
    }
}

From source file:test.hibernate.ExecutionEnvironment.java

License:Open Source License

private void applyMappings(Configuration configuration) {
    String[] mappings = settings.getMappings();
    for (int i = 0; i < mappings.length; i++) {
        configuration.addResource(settings.getBaseForMappings() + mappings[i],
                ExecutionEnvironment.class.getClassLoader());
    }//  w  w w.ja  va2 s .  c  o m
}