Changeset 7729


Ignore:
Timestamp:
Jun 14, 2019, 2:54:55 PM (2 years ago)
Author:
Nicklas Nordborg
Message:

References #2185: Upgrade to Hibernate 5.4.x

Fixed the deprecation warning when calling Dialect.getDialect().

Location:
trunk/src/core/net/sf/basedb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/HibernateUtil.java

    r7714 r7729  
    5151import net.sf.basedb.core.hibernate.TableExistsWork;
    5252import net.sf.basedb.core.query.QueryType;
     53import net.sf.basedb.util.ClassUtil;
    5354import net.sf.basedb.util.FileUtil;
    5455import net.sf.basedb.util.RegexpFileFilter;
     
    212213
    213214      // Get the database dialect and create a DbEngine
    214       dialect = Dialect.getDialect(baseConfig);
     215      String dialectClass = baseConfig.getProperty("hibernate.dialect");
     216      dialect = ClassUtil.newInstance(null, dialectClass, Dialect.class);
    215217      dbEngine = EngineFactory.createEngine(dialect);
    216218    }
  • trunk/src/core/net/sf/basedb/util/ClassUtil.java

    r7513 r7729  
    5757    }
    5858    catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ex)
     59    {
     60      throw new BaseException(ex);
     61    }
     62  }
     63 
     64  /**
     65    Utility method for creating a new instance from a class (given by name)
     66    with a default no-argument constructor. Exceptions are wrapped in BaseExceptions.
     67    @since 3.16
     68    @see #checkAndLoadClass(ClassLoader, String, boolean, Class, Class...)
     69  */
     70  public static <I> I newInstance(ClassLoader classLoader, String name, Class<I> iface, Class<?>... interfaces)
     71  {
     72    try
     73    {
     74      Class<? extends I> clazz = checkAndLoadClass(classLoader, name, true, iface, interfaces);
     75      return clazz.getDeclaredConstructor().newInstance();
     76    }
     77    catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ex)
    5978    {
    6079      throw new BaseException(ex);
Note: See TracChangeset for help on using the changeset viewer.