agave-common/common-core/src/main/java/org/iplantc/service/common/persistence/HibernateUtil.java
/**
	 * Rebuild the SessionFactory with the given Hibernate Configuration.
	 *
	 * @param cfg
	 */
Rebuild the SessionFactory with the given Hibernate Configuration.
@param cfg
Rebuild the SessionFactory with the given Hibernate Configuration . @param cfg
public static void rebuildSessionFactory(Configuration cfg)
	throws PersistenceException 
	{
		synchronized(sessionFactory) {
			try {
				Reflections reflections = new Reflections(new ConfigurationBuilder()
					.filterInputsBy(new FilterBuilder().includePackage("org.iplantc.service"))
					.addUrls(ClasspathHelper.forPackage("org.iplantc.service"))
					.addUrls(ClasspathHelper.forClass(Entity.class))
					.setScanners(new ResourcesScanner(), 
				             new TypeAnnotationsScanner(), 
				             new SubTypesScanner()));
				Set<Class<?>> jpaEntities = reflections.getTypesAnnotatedWith(Entity.class);
				for (Class<?> clazz: jpaEntities) {
					cfg.addAnnotatedClass(clazz);
				}
				cfg.setNamingStrategy(new ImprovedNamingStrategy());
				sessionFactory = cfg.buildSessionFactory();
				configuration = cfg;
			} catch (Exception ex) {
				throw new PersistenceException(ex);
			}
		}
	 }
public static void rebuildSessionFactory ( Configuration cfg ) throws PersistenceException { synchronized ( sessionFactory ) { try { Reflections reflections = new Reflections ( new ConfigurationBuilder ( ) . filterInputsBy ( new FilterBuilder ( ) . includePackage ( "org.iplantc.service" ) ) . addUrls ( ClasspathHelper . forPackage ( "org.iplantc.service" ) ) . addUrls ( ClasspathHelper . forClass ( Entity . class ) ) . setScanners ( new ResourcesScanner ( ) , new TypeAnnotationsScanner ( ) , new SubTypesScanner ( ) ) ) ; Set < Class < ? > > jpaEntities = reflections . getTypesAnnotatedWith ( Entity . class ) ; for ( Class < ? > clazz : jpaEntities ) { cfg . addAnnotatedClass ( clazz ) ; } cfg . setNamingStrategy ( new ImprovedNamingStrategy ( ) ) ; sessionFactory = cfg . buildSessionFactory ( ) ; configuration = cfg ; } catch ( Exception ex ) { throw new PersistenceException ( ex ) ; } } }
Rebuild the SessionFactory with the given Hibernate Configuration.
Rebuild the SessionFactory with the given Hibernate Configuration .