From a8ef4770424310bb9a6301a522e8243a4b0c084d Mon Sep 17 00:00:00 2001 From: Benjamin Phillippe Date: Thu, 16 Oct 2014 10:50:22 -0500 Subject: [PATCH] Omaha #3454 Upgrading to Hibernate 4.2.15 Change-Id: I4ab0970abf9755f69e09ad3d9c79084b76761c29 Former-commit-id: e6deeb6fb50bd9736379031900ca2a69691910f8 [formerly 7845e8e40fadc981a118818bfc3d59b032e8c3c9] [formerly fdd16051e8432c108d6e3901cdf20da4d7d64be9 [formerly 293e59403b6d6e1d792d9fc6d8a0ac106a490bf5]] Former-commit-id: fdd16051e8432c108d6e3901cdf20da4d7d64be9 Former-commit-id: 5eec33b078c55b3d431c923d5bb61eb771496f85 --- .../db/hibernateConfig/maps/hibernate.cfg.xml | 2 +- .../metadata/hibernate.cfg.xml | 2 +- .../build.edex/esb/conf/spring/edex-db.xml | 4 +- .../edex/plugin/gfe/db/dao/GFED2DDao.java | 9 +- .../edex/plugin/gfe/db/dao/GFEDao.java | 157 +++++++++--------- .../edex/plugin/gfe/db/dao/GFELockDao.java | 9 +- .../edex/plugin/gfe/isc/IscSendQueue.java | 8 +- .../plugin/gfe/reference/DbShapeSource.java | 3 +- .../plugin/gfe/smartinit/SmartInitQueue.java | 3 +- .../plugin/radar/dao/RadarStationDao.java | 8 +- .../edex/plugin/shef/database/PostTables.java | 5 +- .../common/activetable/ActiveTableRecord.java | 3 +- .../common/dataplugin/ccfp/CcfpLocation.java | 3 +- .../dataplugin/gfe/db/type/OriginHibType.java | 20 ++- .../dataplugin/gfe/db/type/ParmIdType.java | 19 ++- .../dataplugin/gfe/db/type/WsIdType.java | 35 ++-- .../dataplugin/goessounding/GOESSounding.java | 3 +- .../common/dataplugin/radar/RadarStation.java | 3 +- .../dataplugin/satellite/SatMapCoverage.java | 3 +- .../warning/AbstractWarningRecord.java | 3 +- .../uf/common/gridcoverage/GridCoverage.java | 3 +- .../schemas/ebxml/util/DurationType.java | 19 ++- .../schemas/ebxml/util/ObjectIdGenerator.java | 3 +- .../schemas/ebxml/util/SerializedType.java | 17 +- .../ebxml/util/XMLGregorianCalendarType.java | 18 +- .../META-INF/MANIFEST.MF | 3 +- .../res/spring/metartohmdb-plugin.xml | 2 +- .../ogc/common/db/SQLParamRestriction.java | 3 +- .../res/spring/ohd-common-database.xml | 4 +- .../META-INF/MANIFEST.MF | 3 +- .../acarssounding/dao/ACARSSoundingDao.java | 3 +- .../uf/edex/plugin/grid/dao/GridDao.java | 8 +- .../edex/plugin/npp/viirs/dao/VIIRSDao.java | 4 +- .../res/spring/text-common.xml | 2 +- .../plugin/text/dao/StdTextProductDao.java | 38 +++-- .../edex/plugin/text/dao/SubscriptionDAO.java | 23 ++- .../ebxml/dao/AuditableEventTypeDao.java | 3 +- .../uf/edex/registry/ebxml/dao/DbInit.java | 7 +- .../dao/EbxmlPostgresValidationStrategy.java | 7 +- .../dao/IEbxmlDatabaseValidationStrategy.java | 5 +- .../registry/ebxml/dao/RegistryObjectDao.java | 5 +- .../ebxml/dao/RegistryObjectTypeDao.java | 4 +- .../edex/registry/ebxml/dao/SlotTypeDao.java | 9 +- .../registry/ebxml/dao/SubscriptionDao.java | 4 +- .../web/WEB-INF/web.xml | 2 +- .../wfs/filter/v1_1_0/QueryFilterVisitor.java | 3 +- .../wfs/filter/v2_0_0/QueryFilterVisitor.java | 5 +- .../uf/edex/wfs/provider/FeatureFetcher.java | 3 +- .../uf/edex/wfs/reg/AbstractWfsSource.java | 3 +- .../dataplugin/geomag/dao/GeoMagAvgDao.java | 8 +- .../dataplugin/geomag/dao/GeoMagK1minDao.java | 10 +- .../dataplugin/geomag/dao/GeoMagK3hrDao.java | 8 +- .../META-INF/MANIFEST.MF | 3 +- .../dataplugin/mcidas/McidasMapCoverage.java | 2 +- .../res/spring/ncep-common.xml | 2 +- .../edex/common/dao/NcepDefaultPluginDao.java | 8 +- .../common/dao/NcepPointDataPluginDao.java | 3 +- .../META-INF/MANIFEST.MF | 3 +- .../ncep/edex/plugin/aww/dao/AwwVtecDao.java | 9 +- 59 files changed, 301 insertions(+), 270 deletions(-) diff --git a/edexOsgi/build.edex/esb/conf/db/hibernateConfig/maps/hibernate.cfg.xml b/edexOsgi/build.edex/esb/conf/db/hibernateConfig/maps/hibernate.cfg.xml index dd5fd7930c..54e22c0311 100644 --- a/edexOsgi/build.edex/esb/conf/db/hibernateConfig/maps/hibernate.cfg.xml +++ b/edexOsgi/build.edex/esb/conf/db/hibernateConfig/maps/hibernate.cfg.xml @@ -31,7 +31,7 @@ org.postgresql.Driver - org.hibernatespatial.postgis.PostgisDialect + org.hibernate.spatial.dialect.postgis.PostgisDialect jdbc:postgresql://${db.addr}:${db.port}/maps diff --git a/edexOsgi/build.edex/esb/conf/db/hibernateConfig/metadata/hibernate.cfg.xml b/edexOsgi/build.edex/esb/conf/db/hibernateConfig/metadata/hibernate.cfg.xml index 527e03560e..84e86818af 100644 --- a/edexOsgi/build.edex/esb/conf/db/hibernateConfig/metadata/hibernate.cfg.xml +++ b/edexOsgi/build.edex/esb/conf/db/hibernateConfig/metadata/hibernate.cfg.xml @@ -31,7 +31,7 @@ org.postgresql.Driver - org.hibernatespatial.postgis.PostgisDialect + org.hibernate.spatial.dialect.postgis.PostgisDialect jdbc:postgresql://${db.addr}:${db.port}/metadata diff --git a/edexOsgi/build.edex/esb/conf/spring/edex-db.xml b/edexOsgi/build.edex/esb/conf/spring/edex-db.xml index c764b51416..23f3f1dddd 100644 --- a/edexOsgi/build.edex/esb/conf/spring/edex-db.xml +++ b/edexOsgi/build.edex/esb/conf/spring/edex-db.xml @@ -37,7 +37,7 @@ + class="org.springframework.orm.hibernate4.HibernateTransactionManager"> @@ -55,7 +55,7 @@ + class="org.springframework.orm.hibernate4.HibernateTransactionManager"> diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java index c2f3cf286f..43f7c6b465 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java @@ -59,6 +59,7 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao; * where query for T (T%hr) returned TP6hr * Jun 13, 2013 2044 randerso Cleaned up JavaDoc * Aug 30, 2013 2298 rjpeter Make getPluginName abstract + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -130,7 +131,7 @@ public class GFED2DDao extends GridDao { Session s = null; try { - s = getHibernateTemplate().getSessionFactory().openSession(); + s = getSession(); // TODO: clean up so we only make one db query SortedMap rawTimes = queryByParmId(d2dModelName, refTime, d2dParmName, d2dLevel, s); @@ -150,7 +151,7 @@ public class GFED2DDao extends GridDao { try { s.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -278,7 +279,7 @@ public class GFED2DDao extends GridDao { List timeList = new ArrayList(); Session s = null; try { - s = getHibernateTemplate().getSessionFactory().openSession(); + s = getSession(); SortedMap results = queryByParmId(d2dModelName, refTime, d2dParmName, d2dLevel, s); @@ -290,7 +291,7 @@ public class GFED2DDao extends GridDao { try { s.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java index a640565d6e..e1ce7c2b28 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java @@ -106,6 +106,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * 10/15/2013 #2446 randerso Added ORDER BY clause to getOverlappingTimes * 06/12/14 #3244 randerso Improved error handling * 09/21/2014 #3648 randerso Changed to do version purging when new databases are added + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -153,7 +154,7 @@ public class GFEDao extends DefaultPluginDao { Session sess = null; try { - sess = getHibernateTemplate().getSessionFactory().openSession(); + sess = getSession(); sess.setDefaultReadOnly(true); int tries = 0; Transaction tx = null; @@ -202,7 +203,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -242,7 +243,7 @@ public class GFEDao extends DefaultPluginDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory().openSession(); + sess = getSession(); sess.setDefaultReadOnly(true); tx = sess.beginTransaction(); @@ -280,7 +281,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -304,8 +305,7 @@ public class GFEDao extends DefaultPluginDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory() - .openStatelessSession(); + sess = getSessionFactory().openStatelessSession(); tx = sess.beginTransaction(); for (ParmStorageInfo psi : psiList) { @@ -331,7 +331,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -351,8 +351,7 @@ public class GFEDao extends DefaultPluginDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory() - .openStatelessSession(); + sess = getSessionFactory().openStatelessSession(); tx = sess.beginTransaction(); sess.update(psi); tx.commit(); @@ -374,7 +373,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -395,7 +394,7 @@ public class GFEDao extends DefaultPluginDao { Session sess = null; try { - sess = getHibernateTemplate().getSessionFactory().openSession(); + sess = getSession(); sess.setDefaultReadOnly(true); // reattach so dbId doesn't requery @@ -450,7 +449,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -515,18 +514,18 @@ public class GFEDao extends DefaultPluginDao { try { removed = txTemplate .execute(new TransactionCallback>() { + @SuppressWarnings("unchecked") @Override public List doInTransaction( TransactionStatus status) { Date purgeDate = new Date( System.currentTimeMillis() - (REMOVED_DB_PURGE_TIME * TimeUtil.MILLIS_PER_DAY)); - @SuppressWarnings("unchecked") - List removed = getHibernateTemplate() - .find("FROM DatabaseID where removedDate < ?", - purgeDate); - - return removed; + return getCurrentSession() + .createQuery( + "FROM DatabaseID where removedDate < :removedDate") + .setParameter("removedDate", purgeDate) + .list(); } }); } catch (Exception e) { @@ -555,8 +554,10 @@ public class GFEDao extends DefaultPluginDao { return txTemplate.execute(new TransactionCallback() { @Override public Integer doInTransaction(TransactionStatus status) { - return getHibernateTemplate().bulkUpdate( - "DELETE FROM DatabaseID WHERE siteId = ?", siteID); + return getCurrentSession() + .createQuery( + "DELETE FROM DatabaseID WHERE siteId = :siteId") + .setParameter("siteId", siteID).executeUpdate(); } }); } @@ -579,8 +580,7 @@ public class GFEDao extends DefaultPluginDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory() - .openStatelessSession(); + sess = getSessionFactory().openStatelessSession(); tx = sess.beginTransaction(); for (GFERecord rec : records) { // TODO: Update saving a record, currently causes 2 inserts and @@ -608,7 +608,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -632,8 +632,7 @@ public class GFEDao extends DefaultPluginDao { } try { - sess = getHibernateTemplate().getSessionFactory() - .openStatelessSession(); + sess = getSessionFactory().openStatelessSession(); tx = sess.beginTransaction(); // Update insert time @@ -690,7 +689,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -713,15 +712,14 @@ public class GFEDao extends DefaultPluginDao { try { return txTemplate .execute(new TransactionCallback>() { + @SuppressWarnings("unchecked") @Override public List doInTransaction( TransactionStatus status) { - @SuppressWarnings("unchecked") - List result = getHibernateTemplate() - .find("FROM DatabaseID WHERE siteId = ? AND removeddate is null", - siteId); - - return result; + return getCurrentSession() + .createQuery( + "FROM DatabaseID WHERE siteId = :siteId AND removeddate is null") + .setParameter("siteId", siteId).list(); } }); } catch (Exception e) { @@ -746,7 +744,7 @@ public class GFEDao extends DefaultPluginDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory().openSession(); + sess = getSession(); sess.setDefaultReadOnly(true); tx = sess.beginTransaction(); @@ -776,7 +774,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -801,7 +799,7 @@ public class GFEDao extends DefaultPluginDao { try { // stateless session so we can bulk query histories instead of once // per record via hibernate - sess = getHibernateTemplate().getSessionFactory().openSession(); + sess = getSession(); sess.setDefaultReadOnly(true); tx = sess.beginTransaction(); @@ -837,7 +835,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -867,8 +865,7 @@ public class GFEDao extends DefaultPluginDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory() - .openStatelessSession(); + sess = getSessionFactory().openStatelessSession(); tx = sess.beginTransaction(); Query query = sess .createQuery("DELETE FROM GFERecord WHERE parmId = :parmId" @@ -878,7 +875,7 @@ public class GFEDao extends DefaultPluginDao { int rowsDeleted = query.executeUpdate(); tx.commit(); tx = null; - statusHandler.info("Deleted " + rowsDeleted + logger.info("Deleted " + rowsDeleted + " records from the database."); Map, String[]>> fileMap = GfeUtil @@ -893,19 +890,19 @@ public class GFEDao extends DefaultPluginDao { try { dataStore.deleteGroups(groupsToDelete); - if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { - statusHandler.handle(Priority.DEBUG, "Deleted: " + if (logger.isPriorityEnabled(Priority.DEBUG)) { + logger.handle(Priority.DEBUG, "Deleted: " + Arrays.toString(groupsToDelete) + " from " + hdf5File.getName()); } } catch (Exception e) { - statusHandler.handle(Priority.WARN, + logger.handle(Priority.WARN, "Error deleting hdf5 record(s) from file: " + hdf5File.getPath(), e); } } } catch (Exception e) { - statusHandler.error("Error deleting database record(s) for parmId " + logger.error("Error deleting database record(s) for parmId " + parmId + " timeRanges " + times, e); if (tx != null) { @@ -920,7 +917,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -940,14 +937,14 @@ public class GFEDao extends DefaultPluginDao { try { return txTemplate .execute(new TransactionCallback>() { + @SuppressWarnings("unchecked") @Override public List doInTransaction( TransactionStatus status) { - @SuppressWarnings("unchecked") - List result = getHibernateTemplate() - .find("SELECT dataTime.validPeriod FROM GFERecord WHERE parmId = ? ORDER BY dataTime.validPeriod.start", - parmId); - return result; + return getCurrentSession() + .createQuery( + "SELECT dataTime.validPeriod FROM GFERecord WHERE parmId = :parmId ORDER BY dataTime.validPeriod.start") + .setParameter("parmId", parmId).list(); } }); } catch (Exception e) { @@ -972,19 +969,19 @@ public class GFEDao extends DefaultPluginDao { try { return txTemplate .execute(new TransactionCallback>() { + @SuppressWarnings("unchecked") @Override public List doInTransaction( TransactionStatus status) { - @SuppressWarnings("unchecked") - List rval = getHibernateTemplate() - .find("SELECT dataTime.validPeriod" - + " FROM GFERecord WHERE parmId = ?" - + " AND dataTime.validPeriod.start < ?" - + " AND dataTime.validPeriod.end > ?" - + " ORDER BY dataTime.validPeriod.start", - new Object[] { parmId, tr.getEnd(), - tr.getStart() }); - return rval; + Query query = getCurrentSession().createQuery("SELECT dataTime.validPeriod" + + " FROM GFERecord WHERE parmId = :parmId" + + " AND dataTime.validPeriod.start < :start" + + " AND dataTime.validPeriod.end > :end" + + " ORDER BY dataTime.validPeriod.start"); + query.setParameter("parmId", parmId); + query.setParameter("start", tr.getEnd()); + query.setParameter("end", tr.getStart()); + return query.list(); } }); } catch (Exception e) { @@ -1020,7 +1017,7 @@ public class GFEDao extends DefaultPluginDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory() + sess = getSessionFactory() .openStatelessSession(); tx = sess.beginTransaction(); @@ -1059,7 +1056,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -1080,7 +1077,7 @@ public class GFEDao extends DefaultPluginDao { Session sess = null; boolean purged = false; try { - sess = getHibernateTemplate().getSessionFactory().openSession(); + sess = getSessionFactory().openSession(); Transaction tx = sess.beginTransaction(); Object toDelete = sess.get(DatabaseID.class, dbId.getId(), LockOptions.UPGRADE); @@ -1092,13 +1089,13 @@ public class GFEDao extends DefaultPluginDao { tx.commit(); purged = true; } catch (Exception e) { - statusHandler.error("Error purging " + dbId, e); + logger.error("Error purging " + dbId, e); } finally { if (sess != null) { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -1159,7 +1156,7 @@ public class GFEDao extends DefaultPluginDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory() + sess = getSessionFactory() .openStatelessSession(); tx = sess.beginTransaction(); Query q = sess @@ -1182,7 +1179,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -1208,7 +1205,7 @@ public class GFEDao extends DefaultPluginDao { List rows = null; try { - sess = getHibernateTemplate().getSessionFactory() + sess = getSessionFactory() .openStatelessSession(); tx = sess.beginTransaction(); // use intersection of time range, UPDATE statement don't auto join @@ -1253,7 +1250,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -1293,7 +1290,7 @@ public class GFEDao extends DefaultPluginDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory() + sess = getSessionFactory() .openStatelessSession(); tx = sess.beginTransaction(); Query q = sess @@ -1316,7 +1313,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -1368,17 +1365,17 @@ public class GFEDao extends DefaultPluginDao { // TODO: Should this be done from GridParmManager? List results = Collections.emptyList(); try { - final String[] queryParams = { siteId, modelName }; results = txTemplate .execute(new TransactionCallback>() { + @SuppressWarnings("unchecked") @Override public List doInTransaction( TransactionStatus status) { - @SuppressWarnings("unchecked") - List result = getHibernateTemplate() - .find("FROM DatabaseID WHERE siteId = ? AND modelName = ? ORDER BY modelTime DESC LIMIT 1", - (Object[]) queryParams); - return result; + + Query query = getCurrentSession().createQuery("FROM DatabaseID WHERE siteId = :siteId AND modelName = :modelName ORDER BY modelTime DESC LIMIT 1"); + query.setParameter("siteId", siteId); + query.setParameter("modelName",modelName); + return query.list(); } }); } catch (Exception e) { @@ -1409,7 +1406,7 @@ public class GFEDao extends DefaultPluginDao { dbId.setRemovedDate(removedDate); Session sess = null; try { - sess = getHibernateTemplate().getSessionFactory().openSession(); + sess = getSession(); int tries = 0; Transaction tx = null; try { @@ -1445,7 +1442,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -1465,7 +1462,7 @@ public class GFEDao extends DefaultPluginDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory().openSession(); + sess = getSession(); tx = sess.beginTransaction(); sess.saveOrUpdate(gloc); tx.commit(); @@ -1486,7 +1483,7 @@ public class GFEDao extends DefaultPluginDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFELockDao.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFELockDao.java index 2b8c89fdd4..2b395a0042 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFELockDao.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFELockDao.java @@ -52,6 +52,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig; * 06/17/08 #940 bphillip Initial Creation * 04/19/13 #1949 rjpeter Normalized GFE Database. * 06/20/13 #2127 rjpeter Set session to read only. + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @author bphillip @@ -98,7 +99,7 @@ public class GFELockDao extends CoreDao { Transaction tx = null; try { - sess = getHibernateTemplate().getSessionFactory().openSession(); + sess = getSession(); sess.setDefaultReadOnly(true); tx = sess.beginTransaction(); @@ -137,7 +138,7 @@ public class GFELockDao extends CoreDao { try { sess.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } @@ -159,7 +160,7 @@ public class GFELockDao extends CoreDao { Transaction tx = null; try { - s = this.getHibernateTemplate().getSessionFactory() + s = getSessionFactory() .openStatelessSession(); tx = s.beginTransaction(); @@ -185,7 +186,7 @@ public class GFELockDao extends CoreDao { try { s.close(); } catch (Exception e) { - statusHandler.error( + logger.error( "Error occurred closing database session", e); } } diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/isc/IscSendQueue.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/isc/IscSendQueue.java index 8930f626f1..d838d37fc4 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/isc/IscSendQueue.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/isc/IscSendQueue.java @@ -63,6 +63,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig; * May 08, 2012 600 dgilling Re-work logic for handling PENDING * records. * Feb 07, 2014 2357 rjpeter iscSendNotification uri. + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -333,7 +334,7 @@ public class IscSendQueue { for (IscSendRecord record : newJobs) { try { - s = cd.getHibernateTemplate().getSessionFactory().openSession(); + s = cd.getSession(); tx = s.beginTransaction(); boolean foundDupe = false; boolean foundMerge = false; @@ -575,7 +576,7 @@ public class IscSendQueue { CoreDao dao = new CoreDao(DaoConfig.DEFAULT); List pendingToSending = null; try { - lookupSess = dao.getHibernateTemplate().getSessionFactory() + lookupSess = dao.getSessionFactory() .openStatelessSession(); Criteria pendingCrit = lookupSess @@ -607,8 +608,7 @@ public class IscSendQueue { Transaction tx = null; try { - dbModSess = dao.getHibernateTemplate().getSessionFactory() - .openSession(); + dbModSess = dao.getSession(); tx = dbModSess.beginTransaction(); IscSendRecord oldRecord = (IscSendRecord) dbModSess.get( diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/reference/DbShapeSource.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/reference/DbShapeSource.java index 9e6440462a..a1d07d0631 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/reference/DbShapeSource.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/reference/DbShapeSource.java @@ -37,7 +37,7 @@ import org.geotools.data.simple.SimpleFeatureIterator; import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.factory.CommonFactoryFinder; import org.geotools.factory.GeoTools; -import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.engine.spi.SessionFactoryImplementor; import org.opengis.feature.IllegalAttributeException; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; @@ -71,6 +71,7 @@ import com.vividsolutions.jts.geom.Polygon; * Mar 28, 2013 #1837 dgilling Change error handling in * getLastUpdated(). * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/smartinit/SmartInitQueue.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/smartinit/SmartInitQueue.java index 7440cc09d4..805e3819f1 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/smartinit/SmartInitQueue.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/smartinit/SmartInitQueue.java @@ -56,6 +56,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig; * Jun 13, 2013 #2044 randerso Refactored to use IFPServer, * moved smartInit queuing code here * from other modules, general code cleanup + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @author njensen @@ -217,7 +218,7 @@ public class SmartInitQueue { CoreDao cd = new CoreDao(DaoConfig.DEFAULT); Session s = null; try { - s = cd.getHibernateTemplate().getSessionFactory().openSession(); + s = cd.getSession(); Transaction tx = null; SmartInitRecord oldRecord = null; diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/dao/RadarStationDao.java b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/dao/RadarStationDao.java index 596e693750..756c4db368 100644 --- a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/dao/RadarStationDao.java +++ b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/dao/RadarStationDao.java @@ -23,6 +23,7 @@ package com.raytheon.edex.plugin.radar.dao; import java.util.ArrayList; import java.util.List; +import org.hibernate.Session; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Disjunction; import org.hibernate.criterion.Expression; @@ -45,6 +46,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 7/24/07 353 bphillip Initial Check in + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -167,10 +169,8 @@ public class RadarStationDao extends CoreDao { } } crit.add(stationEq); - List stations = getHibernateTemplate() - .findByCriteria(crit); - - return stations; + Session session = getSession(); + return crit.getExecutableCriteria(session).list(); } else { logger.warn("Cannot execute spatial query with less than 3 points"); return new ArrayList(); diff --git a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/database/PostTables.java b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/database/PostTables.java index b457660cff..771e671f8e 100644 --- a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/database/PostTables.java +++ b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/database/PostTables.java @@ -29,8 +29,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.hibernate.connection.ConnectionProvider; -import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; import com.raytheon.edex.plugin.shef.data.ShefData; import com.raytheon.edex.plugin.shef.data.ShefRecord; @@ -87,6 +87,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig; * 04/29/2014 3088 mpduff Change logging class, clean up/optimization. * More performance fixes. * 09/03/2014 mpduff postRiverStatus() writes directly, not via batch + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * diff --git a/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/ActiveTableRecord.java b/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/ActiveTableRecord.java index 2c6463317b..583f8b6dd1 100644 --- a/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/ActiveTableRecord.java +++ b/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/ActiveTableRecord.java @@ -55,6 +55,7 @@ import com.vividsolutions.jts.geom.Geometry; * May 10, 2013 1951 rjpeter Added own id sequence tagging * Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate- * spatial + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @author njensen @@ -144,7 +145,7 @@ public abstract class ActiveTableRecord extends PersistableDataObject { protected boolean ufn; @Column - @Type(type = "org.hibernatespatial.GeometryUserType") + @Type(type = "org.hibernate.spatial.GeometryType") @DynamicSerializeElement protected Geometry geometry; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ccfp/src/com/raytheon/uf/common/dataplugin/ccfp/CcfpLocation.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ccfp/src/com/raytheon/uf/common/dataplugin/ccfp/CcfpLocation.java index 23cb187ee0..0f6385974f 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ccfp/src/com/raytheon/uf/common/dataplugin/ccfp/CcfpLocation.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ccfp/src/com/raytheon/uf/common/dataplugin/ccfp/CcfpLocation.java @@ -48,6 +48,7 @@ import com.vividsolutions.jts.geom.Geometry; * Nov 01, 2013 2361 njensen Remove XML annotations * Apr 15, 2014 3001 bgonzale Refactored to common package, * com.raytheon.uf.common.dataplugin.ccfp. + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -62,7 +63,7 @@ public class CcfpLocation implements ISpatialObject { private static final long serialVersionUID = 8890315829188793187L; @Column(name = "location") - @Type(type = "org.hibernatespatial.GeometryUserType") + @Type(type = "org.hibernate.spatial.GeometryType") @DynamicSerializeElement private Geometry geometry; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/OriginHibType.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/OriginHibType.java index 06ca15d80a..a4ffac0f28 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/OriginHibType.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/OriginHibType.java @@ -27,6 +27,7 @@ import java.sql.SQLException; import java.sql.Types; import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.usertype.UserType; import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory; @@ -42,6 +43,7 @@ import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 4/18/08 875 bphillip Initial Creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -87,29 +89,30 @@ public class OriginHibType implements UserType { public boolean isMutable() { return false; } - + @Override - public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) + public Object nullSafeGet(ResultSet rs, String[] names, + SessionImplementor session, Object owner) throws HibernateException, SQLException { return GridDataHistory.OriginType - .valueOf(resultSet.getString(names[0])); + .valueOf(rs.getString(names[0])); } @Override - public void nullSafeSet(PreparedStatement statement, Object value, int index) - throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor session) throws HibernateException, SQLException { if (value == null) { - statement.setString(index, null); + st.setString(index, null); } else { if (value instanceof GridDataHistory.OriginType) { - statement.setString(index, ((GridDataHistory.OriginType) value) + st.setString(index, ((GridDataHistory.OriginType) value) .name()); } else { throw new HibernateException("value is not of type " + GridDataHistory.OriginType.class.getName()); } } - + } @Override @@ -127,5 +130,4 @@ public class OriginHibType implements UserType { public int[] sqlTypes() { return OriginHibType.SQL_TYPES; } - } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/ParmIdType.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/ParmIdType.java index 23707c1350..2a1506640e 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/ParmIdType.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/ParmIdType.java @@ -27,6 +27,7 @@ import java.sql.SQLException; import java.sql.Types; import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.usertype.UserType; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; @@ -41,6 +42,7 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 4/18/08 875 bphillip Initial Creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -85,20 +87,21 @@ public class ParmIdType implements UserType{ public boolean isMutable() { return false; } - + @Override - public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) + public Object nullSafeGet(ResultSet rs, String[] names, + SessionImplementor session, Object owner) throws HibernateException, SQLException { - return new ParmID(resultSet.getString(names[0])); + return new ParmID(rs.getString(names[0])); } @Override - public void nullSafeSet(PreparedStatement statement, Object value, int index) - throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor session) throws HibernateException, SQLException { if(value == null){ - statement.setString(index, null); + st.setString(index, null); }else{ - statement.setString(index, value.toString()); + st.setString(index, value.toString()); } } @@ -118,6 +121,4 @@ public class ParmIdType implements UserType{ public int[] sqlTypes() { return ParmIdType.SQL_TYPES; } - - } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/WsIdType.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/WsIdType.java index 13c23e5326..9409eea550 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/WsIdType.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/type/WsIdType.java @@ -26,6 +26,7 @@ import java.sql.SQLException; import java.sql.Types; import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.usertype.UserType; import com.raytheon.uf.common.message.WsId; @@ -39,6 +40,7 @@ import com.raytheon.uf.common.message.WsId; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jun 10, 2009 randerso Initial creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -116,40 +118,28 @@ public class WsIdType implements UserType { public boolean isMutable() { return false; } - - /* - * (non-Javadoc) - * - * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, - * java.lang.String[], java.lang.Object) - */ + @Override - public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) + public Object nullSafeGet(ResultSet rs, String[] names, + SessionImplementor session, Object owner) throws HibernateException, SQLException { - String s = resultSet.getString(names[0]); + String s = rs.getString(names[0]); if (s == null) { return null; } - return new WsId(resultSet.getString(names[0])); + return new WsId(rs.getString(names[0])); } - /* - * (non-Javadoc) - * - * @see - * org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, - * java.lang.Object, int) - */ @Override - public void nullSafeSet(PreparedStatement statement, Object value, int index) - throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor session) throws HibernateException, SQLException { if (value == null) { - statement.setString(index, null); + st.setString(index, null); } else { - statement.setString(index, value.toString()); + st.setString(index, value.toString()); } - + } /* @@ -183,5 +173,4 @@ public class WsIdType implements UserType { public int[] sqlTypes() { return WsIdType.SQL_TYPES; } - } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.goessounding/src/com/raytheon/uf/common/dataplugin/goessounding/GOESSounding.java b/edexOsgi/com.raytheon.uf.common.dataplugin.goessounding/src/com/raytheon/uf/common/dataplugin/goessounding/GOESSounding.java index 62e0466b04..1a095c54a4 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.goessounding/src/com/raytheon/uf/common/dataplugin/goessounding/GOESSounding.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.goessounding/src/com/raytheon/uf/common/dataplugin/goessounding/GOESSounding.java @@ -65,6 +65,7 @@ import com.vividsolutions.jts.geom.Geometry; * Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate- * spatial * Aug 30, 2013 2298 rjpeter Make getPluginName abstract + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -94,7 +95,7 @@ public class GOESSounding extends PersistablePluginDataObject implements // The bounding box that contains this observation. @Column - @Type(type = "org.hibernatespatial.GeometryUserType") + @Type(type = "org.hibernate.spatial.GeometryType") @DynamicSerializeElement private Geometry boxGeometry; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/RadarStation.java b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/RadarStation.java index 655e99d065..16547ee0b7 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/RadarStation.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/RadarStation.java @@ -54,6 +54,7 @@ import com.vividsolutions.jts.geom.Point; * Jul 24, 2007 353 bphillip Initial Check in * Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate- * spatial + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -118,7 +119,7 @@ public class RadarStation extends PersistableDataObject implements private Float lon; @Column(name = "the_geom") - @Type(type = "org.hibernatespatial.GeometryUserType") + @Type(type = "org.hibernate.spatial.GeometryType") @XmlJavaTypeAdapter(value = GeometryAdapter.class) @DynamicSerializeElement private Point station; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java index eb873a1c68..39428df486 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java @@ -74,6 +74,7 @@ import com.vividsolutions.jts.geom.Polygon; * Sep 30, 2013 2333 mschenke Refactored to store coordinates in CRS * space * Apr 11, 2014 2947 bsteffen Fix equals + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -151,7 +152,7 @@ public class SatMapCoverage extends PersistableDataObject implements /** The map coverage */ @Column(name = "the_geom") - @Type(type = "org.hibernatespatial.GeometryUserType") + @Type(type = "org.hibernate.spatial.GeometryType") @XmlJavaTypeAdapter(value = GeometryAdapter.class) @DynamicSerializeElement private Geometry location; diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/AbstractWarningRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/AbstractWarningRecord.java index f002cbed70..cdbfecfd05 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/AbstractWarningRecord.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/AbstractWarningRecord.java @@ -57,6 +57,7 @@ import com.vividsolutions.jts.geom.Geometry; * Aug 08, 2013 2243 jsanchez Removed super method in copy constructor. * Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Jun 11, 2014 2061 bsteffen Remove IDecoderGettable + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -150,7 +151,7 @@ public abstract class AbstractWarningRecord extends PluginDataObject { private boolean ufn; @Column - @Type(type = "org.hibernatespatial.GeometryUserType") + @Type(type = "org.hibernate.spatial.GeometryType") @DynamicSerializeElement private Geometry geometry; diff --git a/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/GridCoverage.java b/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/GridCoverage.java index 60944f95f1..4cd6a6ff68 100644 --- a/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/GridCoverage.java +++ b/edexOsgi/com.raytheon.uf.common.gridcoverage/src/com/raytheon/uf/common/gridcoverage/GridCoverage.java @@ -79,6 +79,7 @@ import com.vividsolutions.jts.geom.Geometry; * Oct 15, 2013 2473 bsteffen add @XmlSeeAlso for self contained JAXB * context. * Apr 11, 2014 2947 bsteffen Implement IGridGeometryProvider. + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -124,7 +125,7 @@ public abstract class GridCoverage extends PersistableDataObject /** Geometry object holding the corner points of the grid */ @Column(name = "the_geom") - @Type(type = "org.hibernatespatial.GeometryUserType") + @Type(type = "org.hibernate.spatial.GeometryType") @XmlJavaTypeAdapter(value = GeometryAdapter.class) @DynamicSerializeElement protected Geometry geometry; diff --git a/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/DurationType.java b/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/DurationType.java index d061782309..62c752932a 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/DurationType.java +++ b/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/DurationType.java @@ -30,6 +30,7 @@ import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.usertype.UserType; /** @@ -44,6 +45,7 @@ import org.hibernate.usertype.UserType; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 6, 2012 bphillip Initial creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -89,11 +91,12 @@ public class DurationType implements UserType { public boolean isMutable() { return false; } - + @Override - public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) + public Object nullSafeGet(ResultSet rs, String[] names, + SessionImplementor session, Object owner) throws HibernateException, SQLException { - long durationInMilliSeconds = resultSet.getLong((names[0])); + long durationInMilliSeconds = rs.getLong((names[0])); try { return DatatypeFactory.newInstance().newDuration( @@ -105,15 +108,15 @@ public class DurationType implements UserType { } @Override - public void nullSafeSet(PreparedStatement statement, Object value, int index) - throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor session) throws HibernateException, SQLException { if (value == null) { - statement.setLong(index, 0); + st.setLong(index, 0); } else { Duration dur = (Duration) value; - statement.setLong(index, dur.getTimeInMillis(new java.util.Date())); + st.setLong(index, dur.getTimeInMillis(new java.util.Date())); } - + } @Override diff --git a/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/ObjectIdGenerator.java b/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/ObjectIdGenerator.java index 749e9e2ee5..991137d138 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/ObjectIdGenerator.java +++ b/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/ObjectIdGenerator.java @@ -20,7 +20,7 @@ package com.raytheon.uf.common.registry.schemas.ebxml.util; import org.hibernate.HibernateException; -import org.hibernate.engine.SessionImplementor; +import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.id.IdentifierGenerator; /** @@ -33,6 +33,7 @@ import org.hibernate.id.IdentifierGenerator; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 11, 2012 bphillip Initial creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * diff --git a/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/SerializedType.java b/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/SerializedType.java index 6f4b1ee287..df8db96852 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/SerializedType.java +++ b/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/SerializedType.java @@ -29,6 +29,7 @@ import java.sql.Types; import javax.xml.datatype.XMLGregorianCalendar; import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.usertype.UserType; /** @@ -44,6 +45,7 @@ import org.hibernate.usertype.UserType; * Oct 31, 2013 2361 njensen Use specific JAXBManager instead of SerializationUtil * Nov 14, 2013 2552 bkowal EbxmlJaxbManager is now accessed via getInstance * Dec 04, 2013 2584 dhladky Version based EbxmlJaxbManager + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -89,9 +91,10 @@ public class SerializedType implements UserType { } @Override - public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) + public Object nullSafeGet(ResultSet rs, String[] names, + SessionImplementor session, Object owner) throws HibernateException, SQLException { - String obj = resultSet.getString(names[0]); + String obj = rs.getString(names[0]); if (obj != null) { try { // We always marshall to current version for to XML conversions @@ -106,18 +109,19 @@ public class SerializedType implements UserType { } @Override - public void nullSafeSet(PreparedStatement statement, Object value, int index) - throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor session) throws HibernateException, SQLException { if (value == null) { - statement.setString(index, null); + st.setString(index, null); } else { try { // We always marshall to current version for to XML conversions - statement.setString(index, EbxmlJaxbManager.getInstance() + st.setString(index, EbxmlJaxbManager.getInstance() .getJaxbManager().marshalToXml(value)); } catch (Exception e) { throw new HibernateException("Error storing AnyType data", e); } } + } @Override @@ -135,5 +139,4 @@ public class SerializedType implements UserType { public int[] sqlTypes() { return SerializedType.SQL_TYPES; } - } diff --git a/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/XMLGregorianCalendarType.java b/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/XMLGregorianCalendarType.java index 781f19e983..bfa7c6c41e 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/XMLGregorianCalendarType.java +++ b/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/com/raytheon/uf/common/registry/schemas/ebxml/util/XMLGregorianCalendarType.java @@ -32,6 +32,7 @@ import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.usertype.UserType; /** @@ -47,6 +48,7 @@ import org.hibernate.usertype.UserType; * Feb 21, 2012 #184 bphillip Initial creation * 4/9/2013 1802 bphillip Added null check * 7/29/2013 2191 bphillip Fixed equals method + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -99,10 +101,11 @@ public class XMLGregorianCalendarType implements UserType { } @Override - public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) + public Object nullSafeGet(ResultSet rs, String[] names, + SessionImplementor session, Object owner) throws HibernateException, SQLException { GregorianCalendar cal = new GregorianCalendar(); - Timestamp date = resultSet.getTimestamp(names[0]); + Timestamp date = rs.getTimestamp(names[0]); if (date == null) { return null; } @@ -117,16 +120,16 @@ public class XMLGregorianCalendarType implements UserType { } @Override - public void nullSafeSet(PreparedStatement statement, Object value, int index) - throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor session) throws HibernateException, SQLException { if (value == null) { - statement.setDate(index, null); + st.setDate(index, null); } else { XMLGregorianCalendar cal = (XMLGregorianCalendar) value; - statement.setTimestamp(index, new Timestamp(cal + st.setTimestamp(index, new Timestamp(cal .toGregorianCalendar().getTime().getTime())); } - + } @Override @@ -144,5 +147,4 @@ public class XMLGregorianCalendarType implements UserType { public int[] sqlTypes() { return XMLGregorianCalendarType.SQL_TYPES; } - } diff --git a/edexOsgi/com.raytheon.uf.edex.metartohmdbsrv/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.metartohmdbsrv/META-INF/MANIFEST.MF index fcf36a15d1..ed1414b87b 100644 --- a/edexOsgi/com.raytheon.uf.edex.metartohmdbsrv/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.metartohmdbsrv/META-INF/MANIFEST.MF @@ -9,7 +9,8 @@ Require-Bundle: com.raytheon.edex.common;bundle-version="1.11.1", com.raytheon.uf.edex.decodertools;bundle-version="1.0.0", org.geotools, javax.persistence, - javax.measure + javax.measure, + com.raytheon.uf.common.status;bundle-version="1.14.1" Import-Package: com.raytheon.edex.plugin.obs.metar, com.raytheon.uf.common.dataplugin.obs.metar, com.raytheon.uf.common.wmo, diff --git a/edexOsgi/com.raytheon.uf.edex.metartohmdbsrv/res/spring/metartohmdb-plugin.xml b/edexOsgi/com.raytheon.uf.edex.metartohmdbsrv/res/spring/metartohmdb-plugin.xml index e0a1bbd570..53b20e874a 100644 --- a/edexOsgi/com.raytheon.uf.edex.metartohmdbsrv/res/spring/metartohmdb-plugin.xml +++ b/edexOsgi/com.raytheon.uf.edex.metartohmdbsrv/res/spring/metartohmdb-plugin.xml @@ -15,7 +15,7 @@ + class="org.springframework.orm.hibernate4.HibernateTransactionManager"> diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/SQLParamRestriction.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/SQLParamRestriction.java index 163a93bf70..185d35a4ad 100644 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/SQLParamRestriction.java +++ b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/SQLParamRestriction.java @@ -16,7 +16,7 @@ import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.criterion.CriteriaQuery; import org.hibernate.criterion.Criterion; -import org.hibernate.engine.TypedValue; +import org.hibernate.engine.spi.TypedValue; /** * Hibernate criterion that allows for direct SQL restrictions @@ -28,6 +28,7 @@ import org.hibernate.engine.TypedValue; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Feb 20, 2013 bclement Initial creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * diff --git a/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/ohd-common-database.xml b/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/ohd-common-database.xml index a078adcb08..3c5cbd7783 100644 --- a/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/ohd-common-database.xml +++ b/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/ohd-common-database.xml @@ -22,7 +22,7 @@ + class="org.springframework.orm.hibernate4.HibernateTransactionManager"> @@ -36,7 +36,7 @@ + class="org.springframework.orm.hibernate4.HibernateTransactionManager"> \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.acarssounding/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.acarssounding/META-INF/MANIFEST.MF index 1eaf544ee6..791e60b515 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.acarssounding/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.plugin.acarssounding/META-INF/MANIFEST.MF @@ -11,7 +11,8 @@ Require-Bundle: com.raytheon.uf.edex.plugin.acars;bundle-version="1.11.4", javax.measure, com.raytheon.edex.common, javax.persistence, - com.raytheon.uf.edex.pointdata;bundle-version="1.12.1174" + com.raytheon.uf.edex.pointdata;bundle-version="1.12.1174", + com.raytheon.uf.common.status;bundle-version="1.14.1" Import-Package: com.raytheon.uf.common.dataplugin.acars, com.raytheon.uf.common.dataplugin.acarssounding, com.raytheon.uf.common.pointdata.spatial, diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.acarssounding/src/com/raytheon/uf/edex/plugin/acarssounding/dao/ACARSSoundingDao.java b/edexOsgi/com.raytheon.uf.edex.plugin.acarssounding/src/com/raytheon/uf/edex/plugin/acarssounding/dao/ACARSSoundingDao.java index 910790b468..f9e93d352f 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.acarssounding/src/com/raytheon/uf/edex/plugin/acarssounding/dao/ACARSSoundingDao.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.acarssounding/src/com/raytheon/uf/edex/plugin/acarssounding/dao/ACARSSoundingDao.java @@ -29,6 +29,7 @@ import org.springframework.transaction.support.TransactionCallback; import com.raytheon.edex.db.dao.DefaultPluginDao; import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.acarssounding.ACARSSoundingRecord; +import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.plugin.acarssounding.tools.ACARSSoundingTools; @@ -126,7 +127,7 @@ public class ACARSSoundingDao extends DefaultPluginDao { String query = String.format(QUERY_TIMELIMITS, tailNumber, startTime, stopTime); - if (logger.isDebugEnabled()) { + if (logger.isPriorityEnabled(Priority.DEBUG)) { logger.debug(query); } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grid/src/com/raytheon/uf/edex/plugin/grid/dao/GridDao.java b/edexOsgi/com.raytheon.uf.edex.plugin.grid/src/com/raytheon/uf/edex/plugin/grid/dao/GridDao.java index ea936c0027..a22ec5b8b7 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grid/src/com/raytheon/uf/edex/plugin/grid/dao/GridDao.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.grid/src/com/raytheon/uf/edex/plugin/grid/dao/GridDao.java @@ -242,7 +242,7 @@ public class GridDao extends PluginDao { record.setInfo(GridInfoCache.getInstance().getGridInfo( record.getInfo())); } catch (DataAccessLayerException e) { - statusHandler.handle(Priority.PROBLEM, + logger.handle(Priority.PROBLEM, "Cannot load GridInfoRecord from DB for: " + record.getDataURI(), e); return false; @@ -398,14 +398,14 @@ public class GridDao extends PluginDao { } else { GridInfoCache.getInstance().purgeCache( new ArrayList(orphanedIds)); - statusHandler + logger .warn("Unable to purge model cache of clustered edices"); } } } catch (DataAccessLayerException e1) { - statusHandler.error("Error purging orphaned grid info entries", e1); + logger.error("Error purging orphaned grid info entries", e1); } catch (EdexException e) { - statusHandler.error( + logger.error( "Error sending message to purge grid info topic", e); } } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.npp.viirs/src/com/raytheon/uf/edex/plugin/npp/viirs/dao/VIIRSDao.java b/edexOsgi/com.raytheon.uf.edex.plugin.npp.viirs/src/com/raytheon/uf/edex/plugin/npp/viirs/dao/VIIRSDao.java index 81cc42fd62..395f1dd1de 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.npp.viirs/src/com/raytheon/uf/edex/plugin/npp/viirs/dao/VIIRSDao.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.npp.viirs/src/com/raytheon/uf/edex/plugin/npp/viirs/dao/VIIRSDao.java @@ -110,7 +110,7 @@ public class VIIRSDao extends PluginDao { coverage = (VIIRSSpatialCoverage) obj; break; } else { - statusHandler.handle(Priority.WARN, + logger.handle(Priority.WARN, "VIIRSSpatialCoverage lookup returned type of: " + obj != null ? obj.getClass() .getSimpleName() : null); @@ -118,7 +118,7 @@ public class VIIRSDao extends PluginDao { } } } catch (DataAccessLayerException e) { - statusHandler.handle(Priority.PROBLEM, + logger.handle(Priority.PROBLEM, "Error querying for viirs spatial object", e); } return coverage; diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.text/res/spring/text-common.xml b/edexOsgi/com.raytheon.uf.edex.plugin.text/res/spring/text-common.xml index f04099eadb..82310332a3 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.text/res/spring/text-common.xml +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/res/spring/text-common.xml @@ -46,7 +46,7 @@ + class="org.springframework.orm.hibernate4.HibernateTransactionManager"> diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/dao/StdTextProductDao.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/dao/StdTextProductDao.java index 18eef955c8..d4642bbd93 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/dao/StdTextProductDao.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/dao/StdTextProductDao.java @@ -47,6 +47,7 @@ import org.hibernate.criterion.Order; import org.hibernate.criterion.ProjectionList; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; +import org.springframework.orm.hibernate4.SessionFactoryUtils; import com.raytheon.uf.common.dataplugin.text.db.OperationalStdTextProduct; import com.raytheon.uf.common.dataplugin.text.db.PracticeStdTextProduct; @@ -91,6 +92,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools; * (operational or practice) * May 20, 2014 2536 bclement moved from edex.textdb to edex.plugin.text * Sep 18, 2014 3627 mapeters Updated deprecated {@link TimeTools} usage. + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @author garmendariz @@ -907,7 +909,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - conn = session.connection(); + conn = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); String ccc = null; @@ -1122,7 +1124,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(query1); ps2 = c.prepareStatement(query2); ps3 = c.prepareStatement(query3); @@ -1246,7 +1248,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(query); ps1.setString(1, wmoId); ps1.setInt(2, startTimeSeconds); @@ -1313,7 +1315,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(query1); ps2 = c.prepareStatement(query2); ps3 = c.prepareStatement(query3); @@ -1437,7 +1439,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(query); ps1.setString(1, site); ps1.setInt(2, startTimeSeconds); @@ -1504,7 +1506,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(query1); ps2 = c.prepareStatement(query2); ps1.setString(1, nnnId); @@ -1600,7 +1602,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(query1); ps1.setString(1, wmoId); ps1.setString(2, site); @@ -1667,7 +1669,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(query1); ps1.setString(1, wmoId); ps1.setString(2, site); @@ -1760,7 +1762,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); int count = 0; /* @@ -1909,7 +1911,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(query); ps1.setString(1, wmoId); ps1.setString(2, site); @@ -1967,7 +1969,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(hdrQuery); ps1.setString(1, wmoId); ps1.setString(2, site); @@ -2057,7 +2059,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(hdrQuery); ps1.setString(1, wmoId); ps1.setString(2, site); @@ -2154,7 +2156,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); if (xxxId == null || xxxId.length() > 0) { ps1 = c.prepareStatement(noXxxQuery); @@ -2255,7 +2257,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(hdrQuery); ps1.setString(1, wmoId); @@ -2352,7 +2354,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ps1 = c.prepareStatement(hdrQuery); ps1.setString(1, wmoId); @@ -2452,7 +2454,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); switch (intlProd) { case 0: // fall through @@ -2576,7 +2578,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); switch (intlProd) { case 0: // fall through @@ -2681,7 +2683,7 @@ public class StdTextProductDao extends CoreDao { try { session = getSession(); - c = session.connection(); + c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); ret = read_product(c, wmoId, site, cccId, nnnId, xxxId, version); } catch (SQLException e) { // don't need to worry about rolling back transaction diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/dao/SubscriptionDAO.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/dao/SubscriptionDAO.java index da084c5741..f2646114b5 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/dao/SubscriptionDAO.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/dao/SubscriptionDAO.java @@ -25,7 +25,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.hibernate.Criteria; import org.hibernate.Query; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.support.TransactionCallback; import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; import com.raytheon.uf.common.dataplugin.text.db.SubscriptionRecord; @@ -53,6 +56,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * 04/24/13 1949 rjpeter Removed @Override on delete. * Nov 08, 2013 2361 njensen Chaged method signature of saveOrUpdate(Object) * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @author mfegan @@ -146,10 +150,9 @@ public class SubscriptionDAO extends CoreDao { * * @return the list of subscriptions */ - @SuppressWarnings("unchecked") public List getSubscriptions() { if ((cachedRecords == null) || dirtyRecords) { - List retVal = getHibernateTemplate().loadAll(this.daoClass); + List retVal = loadAll(); if (retVal == null) { logger.info("Unable to perform query, 'null' result returned"); cachedRecords = new ArrayList(); @@ -162,6 +165,20 @@ public class SubscriptionDAO extends CoreDao { return cachedRecords; } + @SuppressWarnings("unchecked") + private List loadAll() { + return (List) txTemplate + .execute(new TransactionCallback>() { + @Override + public List doInTransaction( + TransactionStatus status) { + Criteria criteria = getSession().createCriteria( + daoClass); + return criteria.list(); + } + }); + } + /** * * @param props @@ -204,7 +221,7 @@ public class SubscriptionDAO extends CoreDao { return new ArrayList(); } } catch (DataAccessLayerException e) { - logger.info("Unable to perform query, ", e); + logger.error("Unable to perform query, ", e); return new ArrayList(); } rval = (List) retVal; diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/AuditableEventTypeDao.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/AuditableEventTypeDao.java index 421dbec41f..d874ee252e 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/AuditableEventTypeDao.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/AuditableEventTypeDao.java @@ -70,6 +70,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil; * 10/23/2013 1538 bphillip Changed send time slot to be DateTimeValue instead of integer * 12/2/2013 1829 bphillip Changed to use non generic getter of value type * 01/21/2014 2613 bphillip Modified queries to better handle deletes + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -137,7 +138,7 @@ public class AuditableEventTypeDao extends @Override public void create(AuditableEventType event) { - template.save(event); + getCurrentSession().save(event); } /** diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java index 8afa3e9e5d..69d3899a3c 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java @@ -45,7 +45,7 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; import org.apache.commons.beanutils.PropertyUtils; import org.hibernate.SessionFactory; -import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.cfg.Configuration; import org.hibernate.jdbc.Work; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; @@ -95,6 +95,7 @@ import com.raytheon.uf.edex.registry.ebxml.init.RegistryInitializedListener; * 7/10/2014 1717 bphillip Removed xacml policy admin object * Jul 10, 2014 2914 garmendariz Remove EnvProperties * Jul 28, 2014 3474 dhladky Fixed bad ownership settings. + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @author bphillip @@ -319,12 +320,12 @@ public class DbInit extends com.raytheon.uf.edex.database.init.DbInit implements * {@inheritDoc} */ @Override - protected AnnotationConfiguration getAnnotationConfiguration() { + protected Configuration getConfiguration() { /* * Create a new configuration object which holds all the classes that * this Hibernate SessionFactory is aware of */ - AnnotationConfiguration aConfig = new AnnotationConfiguration(); + Configuration aConfig = new Configuration(); for (Object obj : sessionFactory.getAllClassMetadata().keySet()) { try { Class clazz = Class.forName((String) obj); diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/EbxmlPostgresValidationStrategy.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/EbxmlPostgresValidationStrategy.java index 75b6c72b03..18961cc8b0 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/EbxmlPostgresValidationStrategy.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/EbxmlPostgresValidationStrategy.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.util.List; import org.hibernate.SessionFactory; -import org.hibernate.cfg.AnnotationConfiguration; -import org.hibernate.impl.SessionFactoryImpl; +import org.hibernate.cfg.Configuration; +import org.hibernate.internal.SessionFactoryImpl; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -39,6 +39,7 @@ import com.raytheon.uf.common.status.UFStatus; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 15, 2013 1693 djohnson Initial creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -63,7 +64,7 @@ public class EbxmlPostgresValidationStrategy implements * {@inheritDoc} */ @Override - public boolean isDbValid(AnnotationConfiguration aConfig, + public boolean isDbValid(Configuration aConfig, SessionFactory sessionFactory) { statusHandler.info("Verifying RegRep database..."); final List existingTables = new ArrayList(); diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/IEbxmlDatabaseValidationStrategy.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/IEbxmlDatabaseValidationStrategy.java index c288e330fe..24ca75f59e 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/IEbxmlDatabaseValidationStrategy.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/IEbxmlDatabaseValidationStrategy.java @@ -20,7 +20,7 @@ package com.raytheon.uf.edex.registry.ebxml.dao; import org.hibernate.SessionFactory; -import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.cfg.Configuration; /** * Database validation strategy. @@ -32,6 +32,7 @@ import org.hibernate.cfg.AnnotationConfiguration; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 15, 2013 1693 djohnson Initial creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -51,7 +52,7 @@ public interface IEbxmlDatabaseValidationStrategy { * the session factory * @return true if valid */ - boolean isDbValid(AnnotationConfiguration aConfig, + boolean isDbValid(Configuration aConfig, SessionFactory sessionFactory); } diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/RegistryObjectDao.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/RegistryObjectDao.java index 5b60dc71dd..94ae2b825b 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/RegistryObjectDao.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/RegistryObjectDao.java @@ -46,6 +46,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; * 2/13/2014 2769 bphillip Added read only flags to query methods * 4/11/2014 3011 bphillip Changed merge to not delete unused slots * 4/21/2014 2992 dhladky General list of Registry server nodes. + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -89,7 +90,7 @@ public class RegistryObjectDao extends public void merge(RegistryObjectType newObject, RegistryObjectType existingObject) { newObject.setId(existingObject.getId()); - template.merge(newObject); + getCurrentSession().merge(newObject); } /** @@ -168,7 +169,7 @@ public class RegistryObjectDao extends * The persistent object to delete */ public void deleteWithoutMerge(RegistryObjectType obj) { - this.template.delete(obj); + getCurrentSession().delete(obj); } public void deleteObjectWithoutDeletingChildren(RegistryObjectType obj) diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/RegistryObjectTypeDao.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/RegistryObjectTypeDao.java index 366ef1ced1..1cdd610975 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/RegistryObjectTypeDao.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/RegistryObjectTypeDao.java @@ -26,7 +26,6 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; import org.hibernate.SessionFactory; import org.hibernate.criterion.Property; -import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -47,6 +46,7 @@ import com.raytheon.uf.edex.registry.ebxml.services.query.QueryConstants; * 8/1/2013 1693 bphillip Moved the merge method down to RegistryObjectDao * 10/8/2013 1682 bphillip Added like lid method, changed to use criteria queries for simple operations * 2/13/2014 2769 bphillip Added read only flags to query methods + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -245,7 +245,7 @@ public abstract class RegistryObjectTypeDao @Override public void setSessionFactory(SessionFactory sessionFactory) { - template = new HibernateTemplate(sessionFactory); + this.sessionFactory = sessionFactory; } @Override diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/SlotTypeDao.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/SlotTypeDao.java index ebe6ba4096..e9eb193492 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/SlotTypeDao.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/SlotTypeDao.java @@ -43,6 +43,7 @@ import com.raytheon.uf.edex.registry.ebxml.services.query.QueryConstants; * 7/11/2013 1707 bphillip Initial implementation * 7/29/2013 2191 bphillip Modified method to get orphaned slots * 12/2/2013 1829 bphillip Changed how orphans are purged + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @author bphillip @@ -84,13 +85,15 @@ public class SlotTypeDao extends SessionManagedDao { public void deleteBySlotId(String id) { SlotType slot = this.getById(id); if (slot != null) { - this.template.delete(slot); + getCurrentSession().delete(slot); } } public void deleteBySlotId(Collection ids){ - template.deleteAll(createCriteria().add( + for(Object obj: createCriteria().add( Property.forName(QueryConstants.ID).in(ids)) - .list()); + .list()){ + getCurrentSession().delete(obj); + } } } diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/SubscriptionDao.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/SubscriptionDao.java index 8651fb25b5..725d9c9766 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/SubscriptionDao.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/SubscriptionDao.java @@ -44,6 +44,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; * 3/13/2013 1082 bphillip Initial creation * 9/5/2013 1538 bphillip Added eagerLoadAll method * 2/13/2014 2769 bphillip Added read only flags to query methods + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @@ -78,8 +79,7 @@ public class SubscriptionDao extends RegistryObjectTypeDao { */ @Transactional(propagation = Propagation.REQUIRED, readOnly = true) public List eagerLoadAll() throws EbxmlRegistryException { - List subs = this.template - .loadAll(SubscriptionType.class); + List subs = super.loadAll(); for (SubscriptionType sub : subs) { try { /* diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/WEB-INF/web.xml b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/WEB-INF/web.xml index 148684d12d..21cb8a0f93 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/WEB-INF/web.xml +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web/WEB-INF/web.xml @@ -71,7 +71,7 @@ hibernateFilter - org.springframework.orm.hibernate3.support.OpenSessionInViewFilter + org.springframework.orm.hibernate4.support.OpenSessionInViewFilter singleSession true diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/v1_1_0/QueryFilterVisitor.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/v1_1_0/QueryFilterVisitor.java index be0445fbf6..10932ea09a 100644 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/v1_1_0/QueryFilterVisitor.java +++ b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/v1_1_0/QueryFilterVisitor.java @@ -43,7 +43,7 @@ import org.hibernate.criterion.Disjunction; import org.hibernate.criterion.Junction; import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.Restrictions; -import org.hibernatespatial.criterion.SpatialRestrictions; +import org.hibernate.spatial.criterion.SpatialRestrictions; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -64,6 +64,7 @@ import com.vividsolutions.jts.geom.Geometry; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 22, 2011 bclement Initial creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/v2_0_0/QueryFilterVisitor.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/v2_0_0/QueryFilterVisitor.java index b9493e86c6..bc23dd16b8 100644 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/v2_0_0/QueryFilterVisitor.java +++ b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/v2_0_0/QueryFilterVisitor.java @@ -42,8 +42,8 @@ import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Disjunction; import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.Restrictions; -import org.hibernatespatial.criterion.SpatialRelateExpression; -import org.hibernatespatial.criterion.SpatialRestrictions; +import org.hibernate.spatial.criterion.SpatialRelateExpression; +import org.hibernate.spatial.criterion.SpatialRestrictions; import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.edex.ogc.common.db.SQLParamRestriction; @@ -73,6 +73,7 @@ import com.vividsolutions.jts.geom.Geometry; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Oct 17, 2012 bclement Initial creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/FeatureFetcher.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/FeatureFetcher.java index a206364ea2..bc9aca33c6 100644 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/FeatureFetcher.java +++ b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/FeatureFetcher.java @@ -29,7 +29,7 @@ import net.opengis.filter.v_1_1_0.FilterType; import org.geotools.geometry.jts.JTS; import org.hibernate.criterion.Criterion; -import org.hibernatespatial.criterion.SpatialRestrictions; +import org.hibernate.spatial.criterion.SpatialRestrictions; import org.opengis.feature.simple.SimpleFeature; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -62,6 +62,7 @@ import com.vividsolutions.jts.geom.Polygon; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 29, 2011 bclement Initial creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/AbstractWfsSource.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/AbstractWfsSource.java index 078bea45f8..27dbc8cf01 100644 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/AbstractWfsSource.java +++ b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/AbstractWfsSource.java @@ -26,8 +26,8 @@ import java.util.List; import java.util.Map; import org.hibernate.Criteria; +import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.hibernate.classic.Session; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Order; import org.hibernate.criterion.Projections; @@ -55,6 +55,7 @@ import com.raytheon.uf.edex.wfs.request.SortBy; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 9, 2012 bclement Initial creation + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * diff --git a/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagAvgDao.java b/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagAvgDao.java index cc410a9ab2..cc5dba232d 100644 --- a/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagAvgDao.java +++ b/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagAvgDao.java @@ -9,7 +9,6 @@ import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; -import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallback; @@ -27,6 +26,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * ------------ ---------- ---------------- -------------------------- * 08/14/2013 T989 qzhou Initial creation. * 03/13/2014 sgurung Added method purgeDataByRefTime() + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @author qzhou @@ -63,8 +63,7 @@ public class GeoMagAvgDao extends CoreDao { return (List) txTemplate.execute(new TransactionCallback() { @Override public Object doInTransaction(TransactionStatus status) { - HibernateTemplate ht = getHibernateTemplate(); - Session sess = ht.getSessionFactory().getCurrentSession(); + Session sess = getCurrentSession(); Criteria crit = sess.createCriteria(GeoMagAvg.class); Criterion where1 = Restrictions.eq("stationCode", stationCode); crit.add(where1); @@ -82,8 +81,7 @@ public class GeoMagAvgDao extends CoreDao { return (List) txTemplate.execute(new TransactionCallback() { @Override public Object doInTransaction(TransactionStatus status) { - HibernateTemplate ht = getHibernateTemplate(); - Session sess = ht.getSessionFactory().getCurrentSession(); + Session sess = getCurrentSession(); Criteria crit = sess.createCriteria(GeoMagAvg.class); Criterion where1 = Restrictions.eq("stationCode", stationCode); crit.add(where1); diff --git a/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagK1minDao.java b/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagK1minDao.java index 454c24d1c2..9a5bf7f247 100644 --- a/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagK1minDao.java +++ b/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagK1minDao.java @@ -9,7 +9,6 @@ import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; -import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallback; @@ -28,6 +27,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * 08/14/2013 T989 qzhou Initial creation. * 03/03/2014 #1110 qzhou Added method getRangeK1min(), Cleaned code * 03/13/2014 sgurung Added method purgeDataByRefTime() + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @author qzhou @@ -55,9 +55,7 @@ public class GeoMagK1minDao extends CoreDao { .execute(new TransactionCallback() { @Override public Object doInTransaction(TransactionStatus status) { - HibernateTemplate ht = getHibernateTemplate(); - Session sess = ht.getSessionFactory() - .getCurrentSession(); + Session sess = getCurrentSession(); Criteria crit = sess.createCriteria(GeoMagK1min.class); Criterion where1 = Restrictions.eq("stationCode", stationCode); @@ -80,9 +78,7 @@ public class GeoMagK1minDao extends CoreDao { .execute(new TransactionCallback() { @Override public Object doInTransaction(TransactionStatus status) { - HibernateTemplate ht = getHibernateTemplate(); - Session sess = ht.getSessionFactory() - .getCurrentSession(); + Session sess = getCurrentSession(); Criteria crit = sess.createCriteria(GeoMagK1min.class); Criterion where1 = Restrictions.eq("stationCode", stationCode); diff --git a/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagK3hrDao.java b/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagK3hrDao.java index 7fb3100db0..1b7cceb5b4 100644 --- a/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagK3hrDao.java +++ b/ncep/gov.noaa.nws.ncep.common.dataplugin.geomag/src/gov/noaa/nws/ncep/common/dataplugin/geomag/dao/GeoMagK3hrDao.java @@ -9,7 +9,6 @@ import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; -import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallback; @@ -27,6 +26,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * ------------ ---------- ---------------- -------------------------- * 08/14/2013 T989 qzhou Initial creation. * 03/13/2014 sgurung Added method purgeDataByRefTime() + * 10/16/2014 3454 bphillip Upgrading to Hibernate 4 * * * @author qzhou @@ -52,8 +52,7 @@ public class GeoMagK3hrDao extends CoreDao { return (List) txTemplate.execute(new TransactionCallback() { @Override public Object doInTransaction(TransactionStatus status) { - HibernateTemplate ht = getHibernateTemplate(); - Session sess = ht.getSessionFactory().getCurrentSession(); + Session sess = getCurrentSession(); Criteria crit = sess.createCriteria(GeoMagK3hr.class); Criterion where1 = Restrictions.eq("stationCode", stationCode); crit.add(where1); @@ -73,8 +72,7 @@ public class GeoMagK3hrDao extends CoreDao { return (List) txTemplate.execute(new TransactionCallback() { @Override public Object doInTransaction(TransactionStatus status) { - HibernateTemplate ht = getHibernateTemplate(); - Session sess = ht.getSessionFactory().getCurrentSession(); + Session sess = getCurrentSession(); Criteria crit = sess.createCriteria(GeoMagK3hr.class); Criterion where1 = Restrictions.eq("stationCode", stationCode); crit.add(where1); diff --git a/ncep/gov.noaa.nws.ncep.common.dataplugin.mcidas/META-INF/MANIFEST.MF b/ncep/gov.noaa.nws.ncep.common.dataplugin.mcidas/META-INF/MANIFEST.MF index f4da11c2a4..46e68960d1 100644 --- a/ncep/gov.noaa.nws.ncep.common.dataplugin.mcidas/META-INF/MANIFEST.MF +++ b/ncep/gov.noaa.nws.ncep.common.dataplugin.mcidas/META-INF/MANIFEST.MF @@ -16,7 +16,8 @@ Require-Bundle: com.raytheon.edex.common;bundle-version="1.11.17", javax.persistence;bundle-version="1.0.0", org.apache.commons.codec;bundle-version="1.3.0", edu.wisc.ssec.mcidas;bundle-version="1.0.0", - com.raytheon.uf.common.numeric;bundle-version="1.14.0" + com.raytheon.uf.common.numeric;bundle-version="1.14.0", + com.raytheon.uf.common.status;bundle-version="1.14.1" Export-Package: gov.noaa.nws.ncep.common.dataplugin.mcidas, gov.noaa.nws.ncep.common.dataplugin.mcidas.dao, gov.noaa.nws.ncep.common.dataplugin.mcidas.fixed diff --git a/ncep/gov.noaa.nws.ncep.common.dataplugin.mcidas/src/gov/noaa/nws/ncep/common/dataplugin/mcidas/McidasMapCoverage.java b/ncep/gov.noaa.nws.ncep.common.dataplugin.mcidas/src/gov/noaa/nws/ncep/common/dataplugin/mcidas/McidasMapCoverage.java index 02f1ffaffd..ac59a0b0ac 100644 --- a/ncep/gov.noaa.nws.ncep.common.dataplugin.mcidas/src/gov/noaa/nws/ncep/common/dataplugin/mcidas/McidasMapCoverage.java +++ b/ncep/gov.noaa.nws.ncep.common.dataplugin.mcidas/src/gov/noaa/nws/ncep/common/dataplugin/mcidas/McidasMapCoverage.java @@ -198,7 +198,7 @@ public class McidasMapCoverage extends PersistableDataObject implements /** The map coverage */ @Column(name = "the_geom") - @Type(type = "org.hibernatespatial.GeometryUserType") + @Type(type = "org.hibernate.spatial.GeometryType") @XmlJavaTypeAdapter(value = GeometryAdapter.class) @DynamicSerializeElement private Polygon location; diff --git a/ncep/gov.noaa.nws.ncep.edex.common/res/spring/ncep-common.xml b/ncep/gov.noaa.nws.ncep.edex.common/res/spring/ncep-common.xml index 60f450ed20..ccb955ec52 100644 --- a/ncep/gov.noaa.nws.ncep.edex.common/res/spring/ncep-common.xml +++ b/ncep/gov.noaa.nws.ncep.edex.common/res/spring/ncep-common.xml @@ -12,7 +12,7 @@ + class="org.springframework.orm.hibernate4.HibernateTransactionManager"> diff --git a/ncep/gov.noaa.nws.ncep.edex.common/src/gov/noaa/nws/ncep/edex/common/dao/NcepDefaultPluginDao.java b/ncep/gov.noaa.nws.ncep.edex.common/src/gov/noaa/nws/ncep/edex/common/dao/NcepDefaultPluginDao.java index 6d554e2e04..a0a2cd663d 100644 --- a/ncep/gov.noaa.nws.ncep.edex.common/src/gov/noaa/nws/ncep/edex/common/dao/NcepDefaultPluginDao.java +++ b/ncep/gov.noaa.nws.ncep.edex.common/src/gov/noaa/nws/ncep/edex/common/dao/NcepDefaultPluginDao.java @@ -1,20 +1,15 @@ package gov.noaa.nws.ncep.edex.common.dao; -import java.io.File; import java.util.ArrayList; -import java.util.Calendar; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; -import com.raytheon.edex.db.dao.DefaultPluginDao; import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.persist.IPersistable; import com.raytheon.uf.common.datastorage.IDataStore; -import com.raytheon.uf.common.util.FileUtil; -import com.raytheon.uf.edex.core.hdf5.HDF5PluginFilenameFilter; import com.raytheon.uf.edex.database.plugin.PluginDao; public class NcepDefaultPluginDao extends PluginDao { @@ -51,8 +46,7 @@ public class NcepDefaultPluginDao extends PluginDao { + " plugin. EDEX will not purge data for " + this.pluginName + " plugin"); } else { - Session s = this.getHibernateTemplate().getSessionFactory() - .openSession(); + Session s = getSession(); Transaction tx = s.beginTransaction(); try { diff --git a/ncep/gov.noaa.nws.ncep.edex.common/src/gov/noaa/nws/ncep/edex/common/dao/NcepPointDataPluginDao.java b/ncep/gov.noaa.nws.ncep.edex.common/src/gov/noaa/nws/ncep/edex/common/dao/NcepPointDataPluginDao.java index 5ce37e18c9..0237945747 100644 --- a/ncep/gov.noaa.nws.ncep.edex.common/src/gov/noaa/nws/ncep/edex/common/dao/NcepPointDataPluginDao.java +++ b/ncep/gov.noaa.nws.ncep.edex.common/src/gov/noaa/nws/ncep/edex/common/dao/NcepPointDataPluginDao.java @@ -48,8 +48,7 @@ public abstract class NcepPointDataPluginDao extends + " plugin. EDEX will not purge data for " + this.pluginName + " plugin"); } else { - Session s = this.getHibernateTemplate().getSessionFactory() - .openSession(); + Session s = getSession(); Transaction tx = s.beginTransaction(); try { diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.aww/META-INF/MANIFEST.MF b/ncep/gov.noaa.nws.ncep.edex.plugin.aww/META-INF/MANIFEST.MF index f713d46d56..a2c38ea035 100644 --- a/ncep/gov.noaa.nws.ncep.edex.plugin.aww/META-INF/MANIFEST.MF +++ b/ncep/gov.noaa.nws.ncep.edex.plugin.aww/META-INF/MANIFEST.MF @@ -13,7 +13,8 @@ Require-Bundle: com.raytheon.edex.common;bundle-version="1.10.13", com.raytheon.uf.common.pointdata;bundle-version="1.11.8", com.raytheon.uf.edex.pointdata;bundle-version="1.11.8", gov.noaa.nws.ncep.common.dataplugin.aww;bundle-version="1.0.0", - org.geotools;bundle-version="2.6.4" + org.geotools;bundle-version="2.6.4", + com.raytheon.uf.common.status;bundle-version="1.14.1" Import-Package: com.raytheon.uf.common.wmo, com.raytheon.uf.edex.decodertools.core, com.raytheon.uf.edex.decodertools.time, diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.aww/src/gov/noaa/nws/ncep/edex/plugin/aww/dao/AwwVtecDao.java b/ncep/gov.noaa.nws.ncep.edex.plugin.aww/src/gov/noaa/nws/ncep/edex/plugin/aww/dao/AwwVtecDao.java index 62e5392003..91f344ac38 100644 --- a/ncep/gov.noaa.nws.ncep.edex.plugin.aww/src/gov/noaa/nws/ncep/edex/plugin/aww/dao/AwwVtecDao.java +++ b/ncep/gov.noaa.nws.ncep.edex.plugin.aww/src/gov/noaa/nws/ncep/edex/plugin/aww/dao/AwwVtecDao.java @@ -1,5 +1,7 @@ package gov.noaa.nws.ncep.edex.plugin.aww.dao; +import gov.noaa.nws.ncep.common.dataplugin.aww.AwwVtec; + import java.sql.Connection; import java.sql.ResultSet; import java.sql.ResultSetMetaData; @@ -9,7 +11,7 @@ import java.util.ArrayList; import java.util.List; import org.hibernate.Session; -import org.hibernate.Transaction; +import org.springframework.orm.hibernate4.SessionFactoryUtils; import com.raytheon.uf.common.dataquery.db.QueryResult; import com.raytheon.uf.common.dataquery.db.QueryResultRow; @@ -17,9 +19,6 @@ import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.dao.CoreDao; import com.raytheon.uf.edex.database.dao.DaoConfig; - -import gov.noaa.nws.ncep.common.dataplugin.aww.AwwVtec; - public class AwwVtecDao extends CoreDao { public AwwVtecDao() { @@ -73,7 +72,7 @@ public class AwwVtecDao extends CoreDao { try { session = getSession(true); - conn = session.connection(); + conn = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); stmt = conn.createStatement(); } catch (SQLException e) {