Coverage Report - com.buckosoft.BuckoVidLib.db.HibernateUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
HibernateUtil
87%
7/8
50%
1/2
1.5
 
 1  
 /******************************************************************************
 2  
  * HibernateUtil.java - Non-object access to the database 
 3  
  * 
 4  
  * BuckoVidLib - The BuckoSoft Video Library
 5  
  * Copyright(c) 2014 - Dick Balaska
 6  
  * 
 7  
  */
 8  
 package com.buckosoft.BuckoVidLib.db;
 9  
 
 10  
 import org.hibernate.SessionFactory;
 11  
 import org.hibernate.cfg.Configuration;
 12  
 
 13  
 /** Non-object access to the database. <br>
 14  
  * This class is really private to DatabaseImpl.
 15  
  * @author Dick Balaska
 16  
  * @since 2014/10/17
 17  
  * @version $Revision: 1.4 $ <br> $Date: 2015/04/12 19:42:15 $
 18  
  */
 19  11
 final class HibernateUtil {
 20  
         private SessionFactory sessionFactory;
 21  11
         private        Configuration configuration = null;
 22  
         
 23  
         @SuppressWarnings("deprecation")
 24  
         protected void initialize(String configFile) {
 25  11
                 if (configFile == null)
 26  0
                         configFile = "BuckoVidLib-hibernate.cfg.xml";
 27  
                 //Properties props = new Properties();
 28  
                 //props.setProperty("hibernate.connection.url",  url);
 29  
                 //if (username != null)
 30  
                 //        props.setProperty("hibernate.connection.username", username);
 31  
                 //if (passwd != null)
 32  
                 //        props.setProperty("hibernate.connection.password",  passwd);
 33  11
                 configuration = new Configuration().configure(configFile);        //.setProperties(props);
 34  11
                 sessionFactory = configuration.buildSessionFactory();                // XXX deprecated use
 35  11
         }
 36  
 
 37  
         protected SessionFactory getSessionFactory() {
 38  281
                 return sessionFactory;
 39  
         }
 40  
 
 41  
         /** Given a string, substitute any System properties in that string.
 42  
          * A property is denoted with {}, i.e. <code>{user.home}</code>
 43  
          * @param in The string to unwind
 44  
          * @return The resultant string.  The original string is returned if no left brace '{' is found.
 45  
          */
 46  
 /*        public static String unwindProperties(String in) {
 47  
                 int i = in.indexOf('{');
 48  
                 if (i == -1)
 49  
                         return(in);
 50  
                 int j = in.indexOf('}');
 51  
                 String out = in.substring(0, i);
 52  
                 String s = System.getProperty(in.substring(i+1, j));
 53  
                 out += s;
 54  
                 out += in.substring(j+1);
 55  
                 return(out);
 56  
         }
 57  
 */
 58  
 }