Omaha #3454 Upgrading to Hibernate 4.2.15

Change-Id: I4ab0970abf9755f69e09ad3d9c79084b76761c29

Former-commit-id: 293e59403b6d6e1d792d9fc6d8a0ac106a490bf5
This commit is contained in:
Benjamin Phillippe 2014-10-16 10:50:22 -05:00
parent 0c5f1c0f78
commit fdd16051e8
59 changed files with 301 additions and 270 deletions

View file

@ -31,7 +31,7 @@
org.postgresql.Driver org.postgresql.Driver
</property> </property>
<property name="dialect"> <property name="dialect">
org.hibernatespatial.postgis.PostgisDialect org.hibernate.spatial.dialect.postgis.PostgisDialect
</property> </property>
<property name="connection.url"> <property name="connection.url">
jdbc:postgresql://${db.addr}:${db.port}/maps jdbc:postgresql://${db.addr}:${db.port}/maps

View file

@ -31,7 +31,7 @@
org.postgresql.Driver org.postgresql.Driver
</property> </property>
<property name="dialect"> <property name="dialect">
org.hibernatespatial.postgis.PostgisDialect org.hibernate.spatial.dialect.postgis.PostgisDialect
</property> </property>
<property name="connection.url"> <property name="connection.url">
jdbc:postgresql://${db.addr}:${db.port}/metadata jdbc:postgresql://${db.addr}:${db.port}/metadata

View file

@ -37,7 +37,7 @@
</bean> </bean>
<bean id="metadataTxManager" <bean id="metadataTxManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="metadataSessionFactory" /> <property name="sessionFactory" ref="metadataSessionFactory" />
</bean> </bean>
@ -55,7 +55,7 @@
</bean> </bean>
<bean id="mapsTxManager" <bean id="mapsTxManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="mapsSessionFactory" /> <property name="sessionFactory" ref="mapsSessionFactory" />
</bean> </bean>

View file

@ -59,6 +59,7 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
* where query for T (T%hr) returned TP6hr * where query for T (T%hr) returned TP6hr
* Jun 13, 2013 2044 randerso Cleaned up JavaDoc * Jun 13, 2013 2044 randerso Cleaned up JavaDoc
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -130,7 +131,7 @@ public class GFED2DDao extends GridDao {
Session s = null; Session s = null;
try { try {
s = getHibernateTemplate().getSessionFactory().openSession(); s = getSession();
// TODO: clean up so we only make one db query // TODO: clean up so we only make one db query
SortedMap<Integer, Integer> rawTimes = queryByParmId(d2dModelName, SortedMap<Integer, Integer> rawTimes = queryByParmId(d2dModelName,
refTime, d2dParmName, d2dLevel, s); refTime, d2dParmName, d2dLevel, s);
@ -150,7 +151,7 @@ public class GFED2DDao extends GridDao {
try { try {
s.close(); s.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -278,7 +279,7 @@ public class GFED2DDao extends GridDao {
List<Integer> timeList = new ArrayList<Integer>(); List<Integer> timeList = new ArrayList<Integer>();
Session s = null; Session s = null;
try { try {
s = getHibernateTemplate().getSessionFactory().openSession(); s = getSession();
SortedMap<Integer, Integer> results = queryByParmId(d2dModelName, SortedMap<Integer, Integer> results = queryByParmId(d2dModelName,
refTime, d2dParmName, d2dLevel, s); refTime, d2dParmName, d2dLevel, s);
@ -290,7 +291,7 @@ public class GFED2DDao extends GridDao {
try { try {
s.close(); s.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }

View file

@ -106,6 +106,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
* 10/15/2013 #2446 randerso Added ORDER BY clause to getOverlappingTimes * 10/15/2013 #2446 randerso Added ORDER BY clause to getOverlappingTimes
* 06/12/14 #3244 randerso Improved error handling * 06/12/14 #3244 randerso Improved error handling
* 09/21/2014 #3648 randerso Changed to do version purging when new databases are added * 09/21/2014 #3648 randerso Changed to do version purging when new databases are added
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -153,7 +154,7 @@ public class GFEDao extends DefaultPluginDao {
Session sess = null; Session sess = null;
try { try {
sess = getHibernateTemplate().getSessionFactory().openSession(); sess = getSession();
sess.setDefaultReadOnly(true); sess.setDefaultReadOnly(true);
int tries = 0; int tries = 0;
Transaction tx = null; Transaction tx = null;
@ -202,7 +203,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -242,7 +243,7 @@ public class GFEDao extends DefaultPluginDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory().openSession(); sess = getSession();
sess.setDefaultReadOnly(true); sess.setDefaultReadOnly(true);
tx = sess.beginTransaction(); tx = sess.beginTransaction();
@ -280,7 +281,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -304,8 +305,7 @@ public class GFEDao extends DefaultPluginDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory() sess = getSessionFactory().openStatelessSession();
.openStatelessSession();
tx = sess.beginTransaction(); tx = sess.beginTransaction();
for (ParmStorageInfo psi : psiList) { for (ParmStorageInfo psi : psiList) {
@ -331,7 +331,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -351,8 +351,7 @@ public class GFEDao extends DefaultPluginDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory() sess = getSessionFactory().openStatelessSession();
.openStatelessSession();
tx = sess.beginTransaction(); tx = sess.beginTransaction();
sess.update(psi); sess.update(psi);
tx.commit(); tx.commit();
@ -374,7 +373,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -395,7 +394,7 @@ public class GFEDao extends DefaultPluginDao {
Session sess = null; Session sess = null;
try { try {
sess = getHibernateTemplate().getSessionFactory().openSession(); sess = getSession();
sess.setDefaultReadOnly(true); sess.setDefaultReadOnly(true);
// reattach so dbId doesn't requery // reattach so dbId doesn't requery
@ -450,7 +449,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -515,18 +514,18 @@ public class GFEDao extends DefaultPluginDao {
try { try {
removed = txTemplate removed = txTemplate
.execute(new TransactionCallback<List<DatabaseID>>() { .execute(new TransactionCallback<List<DatabaseID>>() {
@SuppressWarnings("unchecked")
@Override @Override
public List<DatabaseID> doInTransaction( public List<DatabaseID> doInTransaction(
TransactionStatus status) { TransactionStatus status) {
Date purgeDate = new Date( Date purgeDate = new Date(
System.currentTimeMillis() System.currentTimeMillis()
- (REMOVED_DB_PURGE_TIME * TimeUtil.MILLIS_PER_DAY)); - (REMOVED_DB_PURGE_TIME * TimeUtil.MILLIS_PER_DAY));
@SuppressWarnings("unchecked") return getCurrentSession()
List<DatabaseID> removed = getHibernateTemplate() .createQuery(
.find("FROM DatabaseID where removedDate < ?", "FROM DatabaseID where removedDate < :removedDate")
purgeDate); .setParameter("removedDate", purgeDate)
.list();
return removed;
} }
}); });
} catch (Exception e) { } catch (Exception e) {
@ -555,8 +554,10 @@ public class GFEDao extends DefaultPluginDao {
return txTemplate.execute(new TransactionCallback<Integer>() { return txTemplate.execute(new TransactionCallback<Integer>() {
@Override @Override
public Integer doInTransaction(TransactionStatus status) { public Integer doInTransaction(TransactionStatus status) {
return getHibernateTemplate().bulkUpdate( return getCurrentSession()
"DELETE FROM DatabaseID WHERE siteId = ?", siteID); .createQuery(
"DELETE FROM DatabaseID WHERE siteId = :siteId")
.setParameter("siteId", siteID).executeUpdate();
} }
}); });
} }
@ -579,8 +580,7 @@ public class GFEDao extends DefaultPluginDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory() sess = getSessionFactory().openStatelessSession();
.openStatelessSession();
tx = sess.beginTransaction(); tx = sess.beginTransaction();
for (GFERecord rec : records) { for (GFERecord rec : records) {
// TODO: Update saving a record, currently causes 2 inserts and // TODO: Update saving a record, currently causes 2 inserts and
@ -608,7 +608,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -632,8 +632,7 @@ public class GFEDao extends DefaultPluginDao {
} }
try { try {
sess = getHibernateTemplate().getSessionFactory() sess = getSessionFactory().openStatelessSession();
.openStatelessSession();
tx = sess.beginTransaction(); tx = sess.beginTransaction();
// Update insert time // Update insert time
@ -690,7 +689,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -713,15 +712,14 @@ public class GFEDao extends DefaultPluginDao {
try { try {
return txTemplate return txTemplate
.execute(new TransactionCallback<List<DatabaseID>>() { .execute(new TransactionCallback<List<DatabaseID>>() {
@SuppressWarnings("unchecked")
@Override @Override
public List<DatabaseID> doInTransaction( public List<DatabaseID> doInTransaction(
TransactionStatus status) { TransactionStatus status) {
@SuppressWarnings("unchecked") return getCurrentSession()
List<DatabaseID> result = getHibernateTemplate() .createQuery(
.find("FROM DatabaseID WHERE siteId = ? AND removeddate is null", "FROM DatabaseID WHERE siteId = :siteId AND removeddate is null")
siteId); .setParameter("siteId", siteId).list();
return result;
} }
}); });
} catch (Exception e) { } catch (Exception e) {
@ -746,7 +744,7 @@ public class GFEDao extends DefaultPluginDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory().openSession(); sess = getSession();
sess.setDefaultReadOnly(true); sess.setDefaultReadOnly(true);
tx = sess.beginTransaction(); tx = sess.beginTransaction();
@ -776,7 +774,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -801,7 +799,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
// stateless session so we can bulk query histories instead of once // stateless session so we can bulk query histories instead of once
// per record via hibernate // per record via hibernate
sess = getHibernateTemplate().getSessionFactory().openSession(); sess = getSession();
sess.setDefaultReadOnly(true); sess.setDefaultReadOnly(true);
tx = sess.beginTransaction(); tx = sess.beginTransaction();
@ -837,7 +835,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -867,8 +865,7 @@ public class GFEDao extends DefaultPluginDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory() sess = getSessionFactory().openStatelessSession();
.openStatelessSession();
tx = sess.beginTransaction(); tx = sess.beginTransaction();
Query query = sess Query query = sess
.createQuery("DELETE FROM GFERecord WHERE parmId = :parmId" .createQuery("DELETE FROM GFERecord WHERE parmId = :parmId"
@ -878,7 +875,7 @@ public class GFEDao extends DefaultPluginDao {
int rowsDeleted = query.executeUpdate(); int rowsDeleted = query.executeUpdate();
tx.commit(); tx.commit();
tx = null; tx = null;
statusHandler.info("Deleted " + rowsDeleted logger.info("Deleted " + rowsDeleted
+ " records from the database."); + " records from the database.");
Map<File, Pair<List<TimeRange>, String[]>> fileMap = GfeUtil Map<File, Pair<List<TimeRange>, String[]>> fileMap = GfeUtil
@ -893,19 +890,19 @@ public class GFEDao extends DefaultPluginDao {
try { try {
dataStore.deleteGroups(groupsToDelete); dataStore.deleteGroups(groupsToDelete);
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { if (logger.isPriorityEnabled(Priority.DEBUG)) {
statusHandler.handle(Priority.DEBUG, "Deleted: " logger.handle(Priority.DEBUG, "Deleted: "
+ Arrays.toString(groupsToDelete) + " from " + Arrays.toString(groupsToDelete) + " from "
+ hdf5File.getName()); + hdf5File.getName());
} }
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle(Priority.WARN, logger.handle(Priority.WARN,
"Error deleting hdf5 record(s) from file: " "Error deleting hdf5 record(s) from file: "
+ hdf5File.getPath(), e); + hdf5File.getPath(), e);
} }
} }
} catch (Exception 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); + parmId + " timeRanges " + times, e);
if (tx != null) { if (tx != null) {
@ -920,7 +917,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -940,14 +937,14 @@ public class GFEDao extends DefaultPluginDao {
try { try {
return txTemplate return txTemplate
.execute(new TransactionCallback<List<TimeRange>>() { .execute(new TransactionCallback<List<TimeRange>>() {
@SuppressWarnings("unchecked")
@Override @Override
public List<TimeRange> doInTransaction( public List<TimeRange> doInTransaction(
TransactionStatus status) { TransactionStatus status) {
@SuppressWarnings("unchecked") return getCurrentSession()
List<TimeRange> result = getHibernateTemplate() .createQuery(
.find("SELECT dataTime.validPeriod FROM GFERecord WHERE parmId = ? ORDER BY dataTime.validPeriod.start", "SELECT dataTime.validPeriod FROM GFERecord WHERE parmId = :parmId ORDER BY dataTime.validPeriod.start")
parmId); .setParameter("parmId", parmId).list();
return result;
} }
}); });
} catch (Exception e) { } catch (Exception e) {
@ -972,19 +969,19 @@ public class GFEDao extends DefaultPluginDao {
try { try {
return txTemplate return txTemplate
.execute(new TransactionCallback<List<TimeRange>>() { .execute(new TransactionCallback<List<TimeRange>>() {
@SuppressWarnings("unchecked")
@Override @Override
public List<TimeRange> doInTransaction( public List<TimeRange> doInTransaction(
TransactionStatus status) { TransactionStatus status) {
@SuppressWarnings("unchecked") Query query = getCurrentSession().createQuery("SELECT dataTime.validPeriod"
List<TimeRange> rval = getHibernateTemplate() + " FROM GFERecord WHERE parmId = :parmId"
.find("SELECT dataTime.validPeriod" + " AND dataTime.validPeriod.start < :start"
+ " FROM GFERecord WHERE parmId = ?" + " AND dataTime.validPeriod.end > :end"
+ " AND dataTime.validPeriod.start < ?" + " ORDER BY dataTime.validPeriod.start");
+ " AND dataTime.validPeriod.end > ?" query.setParameter("parmId", parmId);
+ " ORDER BY dataTime.validPeriod.start", query.setParameter("start", tr.getEnd());
new Object[] { parmId, tr.getEnd(), query.setParameter("end", tr.getStart());
tr.getStart() }); return query.list();
return rval;
} }
}); });
} catch (Exception e) { } catch (Exception e) {
@ -1020,7 +1017,7 @@ public class GFEDao extends DefaultPluginDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory() sess = getSessionFactory()
.openStatelessSession(); .openStatelessSession();
tx = sess.beginTransaction(); tx = sess.beginTransaction();
@ -1059,7 +1056,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -1080,7 +1077,7 @@ public class GFEDao extends DefaultPluginDao {
Session sess = null; Session sess = null;
boolean purged = false; boolean purged = false;
try { try {
sess = getHibernateTemplate().getSessionFactory().openSession(); sess = getSessionFactory().openSession();
Transaction tx = sess.beginTransaction(); Transaction tx = sess.beginTransaction();
Object toDelete = sess.get(DatabaseID.class, dbId.getId(), Object toDelete = sess.get(DatabaseID.class, dbId.getId(),
LockOptions.UPGRADE); LockOptions.UPGRADE);
@ -1092,13 +1089,13 @@ public class GFEDao extends DefaultPluginDao {
tx.commit(); tx.commit();
purged = true; purged = true;
} catch (Exception e) { } catch (Exception e) {
statusHandler.error("Error purging " + dbId, e); logger.error("Error purging " + dbId, e);
} finally { } finally {
if (sess != null) { if (sess != null) {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -1159,7 +1156,7 @@ public class GFEDao extends DefaultPluginDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory() sess = getSessionFactory()
.openStatelessSession(); .openStatelessSession();
tx = sess.beginTransaction(); tx = sess.beginTransaction();
Query q = sess Query q = sess
@ -1182,7 +1179,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -1208,7 +1205,7 @@ public class GFEDao extends DefaultPluginDao {
List<Object[]> rows = null; List<Object[]> rows = null;
try { try {
sess = getHibernateTemplate().getSessionFactory() sess = getSessionFactory()
.openStatelessSession(); .openStatelessSession();
tx = sess.beginTransaction(); tx = sess.beginTransaction();
// use intersection of time range, UPDATE statement don't auto join // use intersection of time range, UPDATE statement don't auto join
@ -1253,7 +1250,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -1293,7 +1290,7 @@ public class GFEDao extends DefaultPluginDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory() sess = getSessionFactory()
.openStatelessSession(); .openStatelessSession();
tx = sess.beginTransaction(); tx = sess.beginTransaction();
Query q = sess Query q = sess
@ -1316,7 +1313,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -1368,17 +1365,17 @@ public class GFEDao extends DefaultPluginDao {
// TODO: Should this be done from GridParmManager? // TODO: Should this be done from GridParmManager?
List<DatabaseID> results = Collections.emptyList(); List<DatabaseID> results = Collections.emptyList();
try { try {
final String[] queryParams = { siteId, modelName };
results = txTemplate results = txTemplate
.execute(new TransactionCallback<List<DatabaseID>>() { .execute(new TransactionCallback<List<DatabaseID>>() {
@SuppressWarnings("unchecked")
@Override @Override
public List<DatabaseID> doInTransaction( public List<DatabaseID> doInTransaction(
TransactionStatus status) { TransactionStatus status) {
@SuppressWarnings("unchecked")
List<DatabaseID> result = getHibernateTemplate() Query query = getCurrentSession().createQuery("FROM DatabaseID WHERE siteId = :siteId AND modelName = :modelName ORDER BY modelTime DESC LIMIT 1");
.find("FROM DatabaseID WHERE siteId = ? AND modelName = ? ORDER BY modelTime DESC LIMIT 1", query.setParameter("siteId", siteId);
(Object[]) queryParams); query.setParameter("modelName",modelName);
return result; return query.list();
} }
}); });
} catch (Exception e) { } catch (Exception e) {
@ -1409,7 +1406,7 @@ public class GFEDao extends DefaultPluginDao {
dbId.setRemovedDate(removedDate); dbId.setRemovedDate(removedDate);
Session sess = null; Session sess = null;
try { try {
sess = getHibernateTemplate().getSessionFactory().openSession(); sess = getSession();
int tries = 0; int tries = 0;
Transaction tx = null; Transaction tx = null;
try { try {
@ -1445,7 +1442,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -1465,7 +1462,7 @@ public class GFEDao extends DefaultPluginDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory().openSession(); sess = getSession();
tx = sess.beginTransaction(); tx = sess.beginTransaction();
sess.saveOrUpdate(gloc); sess.saveOrUpdate(gloc);
tx.commit(); tx.commit();
@ -1486,7 +1483,7 @@ public class GFEDao extends DefaultPluginDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }

View file

@ -52,6 +52,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
* 06/17/08 #940 bphillip Initial Creation * 06/17/08 #940 bphillip Initial Creation
* 04/19/13 #1949 rjpeter Normalized GFE Database. * 04/19/13 #1949 rjpeter Normalized GFE Database.
* 06/20/13 #2127 rjpeter Set session to read only. * 06/20/13 #2127 rjpeter Set session to read only.
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* </pre> * </pre>
* *
* @author bphillip * @author bphillip
@ -98,7 +99,7 @@ public class GFELockDao extends CoreDao {
Transaction tx = null; Transaction tx = null;
try { try {
sess = getHibernateTemplate().getSessionFactory().openSession(); sess = getSession();
sess.setDefaultReadOnly(true); sess.setDefaultReadOnly(true);
tx = sess.beginTransaction(); tx = sess.beginTransaction();
@ -137,7 +138,7 @@ public class GFELockDao extends CoreDao {
try { try {
sess.close(); sess.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }
@ -159,7 +160,7 @@ public class GFELockDao extends CoreDao {
Transaction tx = null; Transaction tx = null;
try { try {
s = this.getHibernateTemplate().getSessionFactory() s = getSessionFactory()
.openStatelessSession(); .openStatelessSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
@ -185,7 +186,7 @@ public class GFELockDao extends CoreDao {
try { try {
s.close(); s.close();
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( logger.error(
"Error occurred closing database session", e); "Error occurred closing database session", e);
} }
} }

View file

@ -63,6 +63,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
* May 08, 2012 600 dgilling Re-work logic for handling PENDING * May 08, 2012 600 dgilling Re-work logic for handling PENDING
* records. * records.
* Feb 07, 2014 2357 rjpeter iscSendNotification uri. * Feb 07, 2014 2357 rjpeter iscSendNotification uri.
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -333,7 +334,7 @@ public class IscSendQueue {
for (IscSendRecord record : newJobs) { for (IscSendRecord record : newJobs) {
try { try {
s = cd.getHibernateTemplate().getSessionFactory().openSession(); s = cd.getSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
boolean foundDupe = false; boolean foundDupe = false;
boolean foundMerge = false; boolean foundMerge = false;
@ -575,7 +576,7 @@ public class IscSendQueue {
CoreDao dao = new CoreDao(DaoConfig.DEFAULT); CoreDao dao = new CoreDao(DaoConfig.DEFAULT);
List<IscSendRecord> pendingToSending = null; List<IscSendRecord> pendingToSending = null;
try { try {
lookupSess = dao.getHibernateTemplate().getSessionFactory() lookupSess = dao.getSessionFactory()
.openStatelessSession(); .openStatelessSession();
Criteria pendingCrit = lookupSess Criteria pendingCrit = lookupSess
@ -607,8 +608,7 @@ public class IscSendQueue {
Transaction tx = null; Transaction tx = null;
try { try {
dbModSess = dao.getHibernateTemplate().getSessionFactory() dbModSess = dao.getSession();
.openSession();
tx = dbModSess.beginTransaction(); tx = dbModSess.beginTransaction();
IscSendRecord oldRecord = (IscSendRecord) dbModSess.get( IscSendRecord oldRecord = (IscSendRecord) dbModSess.get(

View file

@ -37,7 +37,7 @@ import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.factory.CommonFactoryFinder; import org.geotools.factory.CommonFactoryFinder;
import org.geotools.factory.GeoTools; 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.IllegalAttributeException;
import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType; 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 * Mar 28, 2013 #1837 dgilling Change error handling in
* getLastUpdated(). * getLastUpdated().
* Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *

View file

@ -56,6 +56,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
* Jun 13, 2013 #2044 randerso Refactored to use IFPServer, * Jun 13, 2013 #2044 randerso Refactored to use IFPServer,
* moved smartInit queuing code here * moved smartInit queuing code here
* from other modules, general code cleanup * from other modules, general code cleanup
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* </pre> * </pre>
* *
* @author njensen * @author njensen
@ -217,7 +218,7 @@ public class SmartInitQueue {
CoreDao cd = new CoreDao(DaoConfig.DEFAULT); CoreDao cd = new CoreDao(DaoConfig.DEFAULT);
Session s = null; Session s = null;
try { try {
s = cd.getHibernateTemplate().getSessionFactory().openSession(); s = cd.getSession();
Transaction tx = null; Transaction tx = null;
SmartInitRecord oldRecord = null; SmartInitRecord oldRecord = null;

View file

@ -23,6 +23,7 @@ package com.raytheon.edex.plugin.radar.dao;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Disjunction; import org.hibernate.criterion.Disjunction;
import org.hibernate.criterion.Expression; import org.hibernate.criterion.Expression;
@ -45,6 +46,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 7/24/07 353 bphillip Initial Check in * 7/24/07 353 bphillip Initial Check in
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -167,10 +169,8 @@ public class RadarStationDao extends CoreDao {
} }
} }
crit.add(stationEq); crit.add(stationEq);
List<RadarStation> stations = getHibernateTemplate() Session session = getSession();
.findByCriteria(crit); return crit.getExecutableCriteria(session).list();
return stations;
} else { } else {
logger.warn("Cannot execute spatial query with less than 3 points"); logger.warn("Cannot execute spatial query with less than 3 points");
return new ArrayList<RadarStation>(); return new ArrayList<RadarStation>();

View file

@ -29,8 +29,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.hibernate.connection.ConnectionProvider; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import com.raytheon.edex.plugin.shef.data.ShefData; import com.raytheon.edex.plugin.shef.data.ShefData;
import com.raytheon.edex.plugin.shef.data.ShefRecord; 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. * 04/29/2014 3088 mpduff Change logging class, clean up/optimization.
* More performance fixes. * More performance fixes.
* 09/03/2014 mpduff postRiverStatus() writes directly, not via batch * 09/03/2014 mpduff postRiverStatus() writes directly, not via batch
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *

View file

@ -55,6 +55,7 @@ import com.vividsolutions.jts.geom.Geometry;
* May 10, 2013 1951 rjpeter Added own id sequence tagging * May 10, 2013 1951 rjpeter Added own id sequence tagging
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate- * Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial * spatial
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* </pre> * </pre>
* *
* @author njensen * @author njensen
@ -144,7 +145,7 @@ public abstract class ActiveTableRecord extends PersistableDataObject {
protected boolean ufn; protected boolean ufn;
@Column @Column
@Type(type = "org.hibernatespatial.GeometryUserType") @Type(type = "org.hibernate.spatial.GeometryType")
@DynamicSerializeElement @DynamicSerializeElement
protected Geometry geometry; protected Geometry geometry;

View file

@ -48,6 +48,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Nov 01, 2013 2361 njensen Remove XML annotations * Nov 01, 2013 2361 njensen Remove XML annotations
* Apr 15, 2014 3001 bgonzale Refactored to common package, * Apr 15, 2014 3001 bgonzale Refactored to common package,
* com.raytheon.uf.common.dataplugin.ccfp. * com.raytheon.uf.common.dataplugin.ccfp.
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* *
* </pre> * </pre>
@ -62,7 +63,7 @@ public class CcfpLocation implements ISpatialObject {
private static final long serialVersionUID = 8890315829188793187L; private static final long serialVersionUID = 8890315829188793187L;
@Column(name = "location") @Column(name = "location")
@Type(type = "org.hibernatespatial.GeometryUserType") @Type(type = "org.hibernate.spatial.GeometryType")
@DynamicSerializeElement @DynamicSerializeElement
private Geometry geometry; private Geometry geometry;

View file

@ -27,6 +27,7 @@ import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory; import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory;
@ -42,6 +43,7 @@ import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 4/18/08 875 bphillip Initial Creation * 4/18/08 875 bphillip Initial Creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -87,29 +89,30 @@ public class OriginHibType implements UserType {
public boolean isMutable() { public boolean isMutable() {
return false; return false;
} }
@Override @Override
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) public Object nullSafeGet(ResultSet rs, String[] names,
SessionImplementor session, Object owner)
throws HibernateException, SQLException { throws HibernateException, SQLException {
return GridDataHistory.OriginType return GridDataHistory.OriginType
.valueOf(resultSet.getString(names[0])); .valueOf(rs.getString(names[0]));
} }
@Override @Override
public void nullSafeSet(PreparedStatement statement, Object value, int index) public void nullSafeSet(PreparedStatement st, Object value, int index,
throws HibernateException, SQLException { SessionImplementor session) throws HibernateException, SQLException {
if (value == null) { if (value == null) {
statement.setString(index, null); st.setString(index, null);
} else { } else {
if (value instanceof GridDataHistory.OriginType) { if (value instanceof GridDataHistory.OriginType) {
statement.setString(index, ((GridDataHistory.OriginType) value) st.setString(index, ((GridDataHistory.OriginType) value)
.name()); .name());
} else { } else {
throw new HibernateException("value is not of type " throw new HibernateException("value is not of type "
+ GridDataHistory.OriginType.class.getName()); + GridDataHistory.OriginType.class.getName());
} }
} }
} }
@Override @Override
@ -127,5 +130,4 @@ public class OriginHibType implements UserType {
public int[] sqlTypes() { public int[] sqlTypes() {
return OriginHibType.SQL_TYPES; return OriginHibType.SQL_TYPES;
} }
} }

View file

@ -27,6 +27,7 @@ import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; 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 * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 4/18/08 875 bphillip Initial Creation * 4/18/08 875 bphillip Initial Creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -85,20 +87,21 @@ public class ParmIdType implements UserType{
public boolean isMutable() { public boolean isMutable() {
return false; return false;
} }
@Override @Override
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) public Object nullSafeGet(ResultSet rs, String[] names,
SessionImplementor session, Object owner)
throws HibernateException, SQLException { throws HibernateException, SQLException {
return new ParmID(resultSet.getString(names[0])); return new ParmID(rs.getString(names[0]));
} }
@Override @Override
public void nullSafeSet(PreparedStatement statement, Object value, int index) public void nullSafeSet(PreparedStatement st, Object value, int index,
throws HibernateException, SQLException { SessionImplementor session) throws HibernateException, SQLException {
if(value == null){ if(value == null){
statement.setString(index, null); st.setString(index, null);
}else{ }else{
statement.setString(index, value.toString()); st.setString(index, value.toString());
} }
} }
@ -118,6 +121,4 @@ public class ParmIdType implements UserType{
public int[] sqlTypes() { public int[] sqlTypes() {
return ParmIdType.SQL_TYPES; return ParmIdType.SQL_TYPES;
} }
} }

View file

@ -26,6 +26,7 @@ import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import com.raytheon.uf.common.message.WsId; import com.raytheon.uf.common.message.WsId;
@ -39,6 +40,7 @@ import com.raytheon.uf.common.message.WsId;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jun 10, 2009 randerso Initial creation * Jun 10, 2009 randerso Initial creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -116,40 +118,28 @@ public class WsIdType implements UserType {
public boolean isMutable() { public boolean isMutable() {
return false; return false;
} }
/*
* (non-Javadoc)
*
* @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet,
* java.lang.String[], java.lang.Object)
*/
@Override @Override
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) public Object nullSafeGet(ResultSet rs, String[] names,
SessionImplementor session, Object owner)
throws HibernateException, SQLException { throws HibernateException, SQLException {
String s = resultSet.getString(names[0]); String s = rs.getString(names[0]);
if (s == null) { if (s == null) {
return 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 @Override
public void nullSafeSet(PreparedStatement statement, Object value, int index) public void nullSafeSet(PreparedStatement st, Object value, int index,
throws HibernateException, SQLException { SessionImplementor session) throws HibernateException, SQLException {
if (value == null) { if (value == null) {
statement.setString(index, null); st.setString(index, null);
} else { } else {
statement.setString(index, value.toString()); st.setString(index, value.toString());
} }
} }
/* /*
@ -183,5 +173,4 @@ public class WsIdType implements UserType {
public int[] sqlTypes() { public int[] sqlTypes() {
return WsIdType.SQL_TYPES; return WsIdType.SQL_TYPES;
} }
} }

View file

@ -65,6 +65,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate- * Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial * spatial
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -94,7 +95,7 @@ public class GOESSounding extends PersistablePluginDataObject implements
// The bounding box that contains this observation. // The bounding box that contains this observation.
@Column @Column
@Type(type = "org.hibernatespatial.GeometryUserType") @Type(type = "org.hibernate.spatial.GeometryType")
@DynamicSerializeElement @DynamicSerializeElement
private Geometry boxGeometry; private Geometry boxGeometry;

View file

@ -54,6 +54,7 @@ import com.vividsolutions.jts.geom.Point;
* Jul 24, 2007 353 bphillip Initial Check in * Jul 24, 2007 353 bphillip Initial Check in
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate- * Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial * spatial
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -118,7 +119,7 @@ public class RadarStation extends PersistableDataObject implements
private Float lon; private Float lon;
@Column(name = "the_geom") @Column(name = "the_geom")
@Type(type = "org.hibernatespatial.GeometryUserType") @Type(type = "org.hibernate.spatial.GeometryType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class) @XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement @DynamicSerializeElement
private Point station; private Point station;

View file

@ -74,6 +74,7 @@ import com.vividsolutions.jts.geom.Polygon;
* Sep 30, 2013 2333 mschenke Refactored to store coordinates in CRS * Sep 30, 2013 2333 mschenke Refactored to store coordinates in CRS
* space * space
* Apr 11, 2014 2947 bsteffen Fix equals * Apr 11, 2014 2947 bsteffen Fix equals
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* *
* </pre> * </pre>
@ -151,7 +152,7 @@ public class SatMapCoverage extends PersistableDataObject<Object> implements
/** The map coverage */ /** The map coverage */
@Column(name = "the_geom") @Column(name = "the_geom")
@Type(type = "org.hibernatespatial.GeometryUserType") @Type(type = "org.hibernate.spatial.GeometryType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class) @XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement @DynamicSerializeElement
private Geometry location; private Geometry location;

View file

@ -57,6 +57,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Aug 08, 2013 2243 jsanchez Removed super method in copy constructor. * Aug 08, 2013 2243 jsanchez Removed super method in copy constructor.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Jun 11, 2014 2061 bsteffen Remove IDecoderGettable * Jun 11, 2014 2061 bsteffen Remove IDecoderGettable
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -150,7 +151,7 @@ public abstract class AbstractWarningRecord extends PluginDataObject {
private boolean ufn; private boolean ufn;
@Column @Column
@Type(type = "org.hibernatespatial.GeometryUserType") @Type(type = "org.hibernate.spatial.GeometryType")
@DynamicSerializeElement @DynamicSerializeElement
private Geometry geometry; private Geometry geometry;

View file

@ -79,6 +79,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Oct 15, 2013 2473 bsteffen add @XmlSeeAlso for self contained JAXB * Oct 15, 2013 2473 bsteffen add @XmlSeeAlso for self contained JAXB
* context. * context.
* Apr 11, 2014 2947 bsteffen Implement IGridGeometryProvider. * Apr 11, 2014 2947 bsteffen Implement IGridGeometryProvider.
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -124,7 +125,7 @@ public abstract class GridCoverage extends PersistableDataObject<Integer>
/** Geometry object holding the corner points of the grid */ /** Geometry object holding the corner points of the grid */
@Column(name = "the_geom") @Column(name = "the_geom")
@Type(type = "org.hibernatespatial.GeometryUserType") @Type(type = "org.hibernate.spatial.GeometryType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class) @XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement @DynamicSerializeElement
protected Geometry geometry; protected Geometry geometry;

View file

@ -30,6 +30,7 @@ import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration; import javax.xml.datatype.Duration;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
/** /**
@ -44,6 +45,7 @@ import org.hibernate.usertype.UserType;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Mar 6, 2012 bphillip Initial creation * Mar 6, 2012 bphillip Initial creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -89,11 +91,12 @@ public class DurationType implements UserType {
public boolean isMutable() { public boolean isMutable() {
return false; return false;
} }
@Override @Override
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) public Object nullSafeGet(ResultSet rs, String[] names,
SessionImplementor session, Object owner)
throws HibernateException, SQLException { throws HibernateException, SQLException {
long durationInMilliSeconds = resultSet.getLong((names[0])); long durationInMilliSeconds = rs.getLong((names[0]));
try { try {
return DatatypeFactory.newInstance().newDuration( return DatatypeFactory.newInstance().newDuration(
@ -105,15 +108,15 @@ public class DurationType implements UserType {
} }
@Override @Override
public void nullSafeSet(PreparedStatement statement, Object value, int index) public void nullSafeSet(PreparedStatement st, Object value, int index,
throws HibernateException, SQLException { SessionImplementor session) throws HibernateException, SQLException {
if (value == null) { if (value == null) {
statement.setLong(index, 0); st.setLong(index, 0);
} else { } else {
Duration dur = (Duration) value; Duration dur = (Duration) value;
statement.setLong(index, dur.getTimeInMillis(new java.util.Date())); st.setLong(index, dur.getTimeInMillis(new java.util.Date()));
} }
} }
@Override @Override

View file

@ -20,7 +20,7 @@
package com.raytheon.uf.common.registry.schemas.ebxml.util; package com.raytheon.uf.common.registry.schemas.ebxml.util;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.IdentifierGenerator;
/** /**
@ -33,6 +33,7 @@ import org.hibernate.id.IdentifierGenerator;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 11, 2012 bphillip Initial creation * Jan 11, 2012 bphillip Initial creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *

View file

@ -29,6 +29,7 @@ import java.sql.Types;
import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.XMLGregorianCalendar;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.usertype.UserType; 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 * Oct 31, 2013 2361 njensen Use specific JAXBManager instead of SerializationUtil
* Nov 14, 2013 2552 bkowal EbxmlJaxbManager is now accessed via getInstance * Nov 14, 2013 2552 bkowal EbxmlJaxbManager is now accessed via getInstance
* Dec 04, 2013 2584 dhladky Version based EbxmlJaxbManager * Dec 04, 2013 2584 dhladky Version based EbxmlJaxbManager
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -89,9 +91,10 @@ public class SerializedType implements UserType {
} }
@Override @Override
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) public Object nullSafeGet(ResultSet rs, String[] names,
SessionImplementor session, Object owner)
throws HibernateException, SQLException { throws HibernateException, SQLException {
String obj = resultSet.getString(names[0]); String obj = rs.getString(names[0]);
if (obj != null) { if (obj != null) {
try { // We always marshall to current version for to XML conversions try { // We always marshall to current version for to XML conversions
@ -106,18 +109,19 @@ public class SerializedType implements UserType {
} }
@Override @Override
public void nullSafeSet(PreparedStatement statement, Object value, int index) public void nullSafeSet(PreparedStatement st, Object value, int index,
throws HibernateException, SQLException { SessionImplementor session) throws HibernateException, SQLException {
if (value == null) { if (value == null) {
statement.setString(index, null); st.setString(index, null);
} else { } else {
try { // We always marshall to current version for to XML conversions try { // We always marshall to current version for to XML conversions
statement.setString(index, EbxmlJaxbManager.getInstance() st.setString(index, EbxmlJaxbManager.getInstance()
.getJaxbManager().marshalToXml(value)); .getJaxbManager().marshalToXml(value));
} catch (Exception e) { } catch (Exception e) {
throw new HibernateException("Error storing AnyType data", e); throw new HibernateException("Error storing AnyType data", e);
} }
} }
} }
@Override @Override
@ -135,5 +139,4 @@ public class SerializedType implements UserType {
public int[] sqlTypes() { public int[] sqlTypes() {
return SerializedType.SQL_TYPES; return SerializedType.SQL_TYPES;
} }
} }

View file

@ -32,6 +32,7 @@ import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.XMLGregorianCalendar;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
/** /**
@ -47,6 +48,7 @@ import org.hibernate.usertype.UserType;
* Feb 21, 2012 #184 bphillip Initial creation * Feb 21, 2012 #184 bphillip Initial creation
* 4/9/2013 1802 bphillip Added null check * 4/9/2013 1802 bphillip Added null check
* 7/29/2013 2191 bphillip Fixed equals method * 7/29/2013 2191 bphillip Fixed equals method
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -99,10 +101,11 @@ public class XMLGregorianCalendarType implements UserType {
} }
@Override @Override
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) public Object nullSafeGet(ResultSet rs, String[] names,
SessionImplementor session, Object owner)
throws HibernateException, SQLException { throws HibernateException, SQLException {
GregorianCalendar cal = new GregorianCalendar(); GregorianCalendar cal = new GregorianCalendar();
Timestamp date = resultSet.getTimestamp(names[0]); Timestamp date = rs.getTimestamp(names[0]);
if (date == null) { if (date == null) {
return null; return null;
} }
@ -117,16 +120,16 @@ public class XMLGregorianCalendarType implements UserType {
} }
@Override @Override
public void nullSafeSet(PreparedStatement statement, Object value, int index) public void nullSafeSet(PreparedStatement st, Object value, int index,
throws HibernateException, SQLException { SessionImplementor session) throws HibernateException, SQLException {
if (value == null) { if (value == null) {
statement.setDate(index, null); st.setDate(index, null);
} else { } else {
XMLGregorianCalendar cal = (XMLGregorianCalendar) value; XMLGregorianCalendar cal = (XMLGregorianCalendar) value;
statement.setTimestamp(index, new Timestamp(cal st.setTimestamp(index, new Timestamp(cal
.toGregorianCalendar().getTime().getTime())); .toGregorianCalendar().getTime().getTime()));
} }
} }
@Override @Override
@ -144,5 +147,4 @@ public class XMLGregorianCalendarType implements UserType {
public int[] sqlTypes() { public int[] sqlTypes() {
return XMLGregorianCalendarType.SQL_TYPES; return XMLGregorianCalendarType.SQL_TYPES;
} }
} }

View file

@ -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", com.raytheon.uf.edex.decodertools;bundle-version="1.0.0",
org.geotools, org.geotools,
javax.persistence, javax.persistence,
javax.measure javax.measure,
com.raytheon.uf.common.status;bundle-version="1.14.1"
Import-Package: com.raytheon.edex.plugin.obs.metar, Import-Package: com.raytheon.edex.plugin.obs.metar,
com.raytheon.uf.common.dataplugin.obs.metar, com.raytheon.uf.common.dataplugin.obs.metar,
com.raytheon.uf.common.wmo, com.raytheon.uf.common.wmo,

View file

@ -15,7 +15,7 @@
</bean> </bean>
<bean id="hmdbTxManager" <bean id="hmdbTxManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="hmdbSessionFactory" /> <property name="sessionFactory" ref="hmdbSessionFactory" />
</bean> </bean>

View file

@ -16,7 +16,7 @@ import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.criterion.CriteriaQuery; import org.hibernate.criterion.CriteriaQuery;
import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Criterion;
import org.hibernate.engine.TypedValue; import org.hibernate.engine.spi.TypedValue;
/** /**
* Hibernate criterion that allows for direct SQL restrictions * Hibernate criterion that allows for direct SQL restrictions
@ -28,6 +28,7 @@ import org.hibernate.engine.TypedValue;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Feb 20, 2013 bclement Initial creation * Feb 20, 2013 bclement Initial creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *

View file

@ -22,7 +22,7 @@
</bean> </bean>
<bean id="ihfsTxManager" <bean id="ihfsTxManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="ihfsSessionFactory" /> <property name="sessionFactory" ref="ihfsSessionFactory" />
</bean> </bean>
@ -36,7 +36,7 @@
</bean> </bean>
<bean id="damTxManager" <bean id="damTxManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="damSessionFactory" /> <property name="sessionFactory" ref="damSessionFactory" />
</bean> </bean>
</beans> </beans>

View file

@ -11,7 +11,8 @@ Require-Bundle: com.raytheon.uf.edex.plugin.acars;bundle-version="1.11.4",
javax.measure, javax.measure,
com.raytheon.edex.common, com.raytheon.edex.common,
javax.persistence, 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, Import-Package: com.raytheon.uf.common.dataplugin.acars,
com.raytheon.uf.common.dataplugin.acarssounding, com.raytheon.uf.common.dataplugin.acarssounding,
com.raytheon.uf.common.pointdata.spatial, com.raytheon.uf.common.pointdata.spatial,

View file

@ -29,6 +29,7 @@ import org.springframework.transaction.support.TransactionCallback;
import com.raytheon.edex.db.dao.DefaultPluginDao; import com.raytheon.edex.db.dao.DefaultPluginDao;
import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.acarssounding.ACARSSoundingRecord; 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.database.DataAccessLayerException;
import com.raytheon.uf.edex.plugin.acarssounding.tools.ACARSSoundingTools; 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, String query = String.format(QUERY_TIMELIMITS, tailNumber, startTime,
stopTime); stopTime);
if (logger.isDebugEnabled()) { if (logger.isPriorityEnabled(Priority.DEBUG)) {
logger.debug(query); logger.debug(query);
} }

View file

@ -242,7 +242,7 @@ public class GridDao extends PluginDao {
record.setInfo(GridInfoCache.getInstance().getGridInfo( record.setInfo(GridInfoCache.getInstance().getGridInfo(
record.getInfo())); record.getInfo()));
} catch (DataAccessLayerException e) { } catch (DataAccessLayerException e) {
statusHandler.handle(Priority.PROBLEM, logger.handle(Priority.PROBLEM,
"Cannot load GridInfoRecord from DB for: " "Cannot load GridInfoRecord from DB for: "
+ record.getDataURI(), e); + record.getDataURI(), e);
return false; return false;
@ -398,14 +398,14 @@ public class GridDao extends PluginDao {
} else { } else {
GridInfoCache.getInstance().purgeCache( GridInfoCache.getInstance().purgeCache(
new ArrayList<Integer>(orphanedIds)); new ArrayList<Integer>(orphanedIds));
statusHandler logger
.warn("Unable to purge model cache of clustered edices"); .warn("Unable to purge model cache of clustered edices");
} }
} }
} catch (DataAccessLayerException e1) { } catch (DataAccessLayerException e1) {
statusHandler.error("Error purging orphaned grid info entries", e1); logger.error("Error purging orphaned grid info entries", e1);
} catch (EdexException e) { } catch (EdexException e) {
statusHandler.error( logger.error(
"Error sending message to purge grid info topic", e); "Error sending message to purge grid info topic", e);
} }
} }

View file

@ -110,7 +110,7 @@ public class VIIRSDao extends PluginDao {
coverage = (VIIRSSpatialCoverage) obj; coverage = (VIIRSSpatialCoverage) obj;
break; break;
} else { } else {
statusHandler.handle(Priority.WARN, logger.handle(Priority.WARN,
"VIIRSSpatialCoverage lookup returned type of: " "VIIRSSpatialCoverage lookup returned type of: "
+ obj != null ? obj.getClass() + obj != null ? obj.getClass()
.getSimpleName() : null); .getSimpleName() : null);
@ -118,7 +118,7 @@ public class VIIRSDao extends PluginDao {
} }
} }
} catch (DataAccessLayerException e) { } catch (DataAccessLayerException e) {
statusHandler.handle(Priority.PROBLEM, logger.handle(Priority.PROBLEM,
"Error querying for viirs spatial object", e); "Error querying for viirs spatial object", e);
} }
return coverage; return coverage;

View file

@ -46,7 +46,7 @@
</bean> </bean>
<bean id="fxaTxManager" <bean id="fxaTxManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="fxaSessionFactory" /> <property name="sessionFactory" ref="fxaSessionFactory" />
</bean> </bean>

View file

@ -47,6 +47,7 @@ import org.hibernate.criterion.Order;
import org.hibernate.criterion.ProjectionList; import org.hibernate.criterion.ProjectionList;
import org.hibernate.criterion.Projections; import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions; 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.OperationalStdTextProduct;
import com.raytheon.uf.common.dataplugin.text.db.PracticeStdTextProduct; import com.raytheon.uf.common.dataplugin.text.db.PracticeStdTextProduct;
@ -91,6 +92,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* (operational or practice) * (operational or practice)
* May 20, 2014 2536 bclement moved from edex.textdb to edex.plugin.text * May 20, 2014 2536 bclement moved from edex.textdb to edex.plugin.text
* Sep 18, 2014 3627 mapeters Updated deprecated {@link TimeTools} usage. * Sep 18, 2014 3627 mapeters Updated deprecated {@link TimeTools} usage.
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* </pre> * </pre>
* *
* @author garmendariz * @author garmendariz
@ -907,7 +909,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
conn = session.connection(); conn = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
String ccc = null; String ccc = null;
@ -1122,7 +1124,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(query1); ps1 = c.prepareStatement(query1);
ps2 = c.prepareStatement(query2); ps2 = c.prepareStatement(query2);
ps3 = c.prepareStatement(query3); ps3 = c.prepareStatement(query3);
@ -1246,7 +1248,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(query); ps1 = c.prepareStatement(query);
ps1.setString(1, wmoId); ps1.setString(1, wmoId);
ps1.setInt(2, startTimeSeconds); ps1.setInt(2, startTimeSeconds);
@ -1313,7 +1315,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(query1); ps1 = c.prepareStatement(query1);
ps2 = c.prepareStatement(query2); ps2 = c.prepareStatement(query2);
ps3 = c.prepareStatement(query3); ps3 = c.prepareStatement(query3);
@ -1437,7 +1439,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(query); ps1 = c.prepareStatement(query);
ps1.setString(1, site); ps1.setString(1, site);
ps1.setInt(2, startTimeSeconds); ps1.setInt(2, startTimeSeconds);
@ -1504,7 +1506,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(query1); ps1 = c.prepareStatement(query1);
ps2 = c.prepareStatement(query2); ps2 = c.prepareStatement(query2);
ps1.setString(1, nnnId); ps1.setString(1, nnnId);
@ -1600,7 +1602,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(query1); ps1 = c.prepareStatement(query1);
ps1.setString(1, wmoId); ps1.setString(1, wmoId);
ps1.setString(2, site); ps1.setString(2, site);
@ -1667,7 +1669,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(query1); ps1 = c.prepareStatement(query1);
ps1.setString(1, wmoId); ps1.setString(1, wmoId);
ps1.setString(2, site); ps1.setString(2, site);
@ -1760,7 +1762,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
int count = 0; int count = 0;
/* /*
@ -1909,7 +1911,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(query); ps1 = c.prepareStatement(query);
ps1.setString(1, wmoId); ps1.setString(1, wmoId);
ps1.setString(2, site); ps1.setString(2, site);
@ -1967,7 +1969,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(hdrQuery); ps1 = c.prepareStatement(hdrQuery);
ps1.setString(1, wmoId); ps1.setString(1, wmoId);
ps1.setString(2, site); ps1.setString(2, site);
@ -2057,7 +2059,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(hdrQuery); ps1 = c.prepareStatement(hdrQuery);
ps1.setString(1, wmoId); ps1.setString(1, wmoId);
ps1.setString(2, site); ps1.setString(2, site);
@ -2154,7 +2156,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
if (xxxId == null || xxxId.length() > 0) { if (xxxId == null || xxxId.length() > 0) {
ps1 = c.prepareStatement(noXxxQuery); ps1 = c.prepareStatement(noXxxQuery);
@ -2255,7 +2257,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(hdrQuery); ps1 = c.prepareStatement(hdrQuery);
ps1.setString(1, wmoId); ps1.setString(1, wmoId);
@ -2352,7 +2354,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ps1 = c.prepareStatement(hdrQuery); ps1 = c.prepareStatement(hdrQuery);
ps1.setString(1, wmoId); ps1.setString(1, wmoId);
@ -2452,7 +2454,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
switch (intlProd) { switch (intlProd) {
case 0: // fall through case 0: // fall through
@ -2576,7 +2578,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
switch (intlProd) { switch (intlProd) {
case 0: // fall through case 0: // fall through
@ -2681,7 +2683,7 @@ public class StdTextProductDao extends CoreDao {
try { try {
session = getSession(); session = getSession();
c = session.connection(); c = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
ret = read_product(c, wmoId, site, cccId, nnnId, xxxId, version); ret = read_product(c, wmoId, site, cccId, nnnId, xxxId, version);
} catch (SQLException e) { } catch (SQLException e) {
// don't need to worry about rolling back transaction // don't need to worry about rolling back transaction

View file

@ -25,7 +25,10 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.hibernate.Criteria;
import org.hibernate.Query; 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.persist.PersistableDataObject;
import com.raytheon.uf.common.dataplugin.text.db.SubscriptionRecord; 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. * 04/24/13 1949 rjpeter Removed @Override on delete.
* Nov 08, 2013 2361 njensen Chaged method signature of saveOrUpdate(Object) * Nov 08, 2013 2361 njensen Chaged method signature of saveOrUpdate(Object)
* May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* </pre> * </pre>
* *
* @author mfegan * @author mfegan
@ -146,10 +150,9 @@ public class SubscriptionDAO extends CoreDao {
* *
* @return the list of subscriptions * @return the list of subscriptions
*/ */
@SuppressWarnings("unchecked")
public List<SubscriptionRecord> getSubscriptions() { public List<SubscriptionRecord> getSubscriptions() {
if ((cachedRecords == null) || dirtyRecords) { if ((cachedRecords == null) || dirtyRecords) {
List<?> retVal = getHibernateTemplate().loadAll(this.daoClass); List<SubscriptionRecord> retVal = loadAll();
if (retVal == null) { if (retVal == null) {
logger.info("Unable to perform query, 'null' result returned"); logger.info("Unable to perform query, 'null' result returned");
cachedRecords = new ArrayList<SubscriptionRecord>(); cachedRecords = new ArrayList<SubscriptionRecord>();
@ -162,6 +165,20 @@ public class SubscriptionDAO extends CoreDao {
return cachedRecords; return cachedRecords;
} }
@SuppressWarnings("unchecked")
private List<SubscriptionRecord> loadAll() {
return (List<SubscriptionRecord>) txTemplate
.execute(new TransactionCallback<List<?>>() {
@Override
public List<SubscriptionRecord> doInTransaction(
TransactionStatus status) {
Criteria criteria = getSession().createCriteria(
daoClass);
return criteria.list();
}
});
}
/** /**
* *
* @param props * @param props
@ -204,7 +221,7 @@ public class SubscriptionDAO extends CoreDao {
return new ArrayList<SubscriptionRecord>(); return new ArrayList<SubscriptionRecord>();
} }
} catch (DataAccessLayerException e) { } catch (DataAccessLayerException e) {
logger.info("Unable to perform query, ", e); logger.error("Unable to perform query, ", e);
return new ArrayList<SubscriptionRecord>(); return new ArrayList<SubscriptionRecord>();
} }
rval = (List<SubscriptionRecord>) retVal; rval = (List<SubscriptionRecord>) retVal;

View file

@ -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 * 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 * 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 * 01/21/2014 2613 bphillip Modified queries to better handle deletes
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -137,7 +138,7 @@ public class AuditableEventTypeDao extends
@Override @Override
public void create(AuditableEventType event) { public void create(AuditableEventType event) {
template.save(event); getCurrentSession().save(event);
} }
/** /**

View file

@ -45,7 +45,7 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.beanutils.PropertyUtils;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Configuration;
import org.hibernate.jdbc.Work; import org.hibernate.jdbc.Work;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext; 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 * 7/10/2014 1717 bphillip Removed xacml policy admin object
* Jul 10, 2014 2914 garmendariz Remove EnvProperties * Jul 10, 2014 2914 garmendariz Remove EnvProperties
* Jul 28, 2014 3474 dhladky Fixed bad ownership settings. * Jul 28, 2014 3474 dhladky Fixed bad ownership settings.
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* </pre> * </pre>
* *
* @author bphillip * @author bphillip
@ -319,12 +320,12 @@ public class DbInit extends com.raytheon.uf.edex.database.init.DbInit implements
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
protected AnnotationConfiguration getAnnotationConfiguration() { protected Configuration getConfiguration() {
/* /*
* Create a new configuration object which holds all the classes that * Create a new configuration object which holds all the classes that
* this Hibernate SessionFactory is aware of * this Hibernate SessionFactory is aware of
*/ */
AnnotationConfiguration aConfig = new AnnotationConfiguration(); Configuration aConfig = new Configuration();
for (Object obj : sessionFactory.getAllClassMetadata().keySet()) { for (Object obj : sessionFactory.getAllClassMetadata().keySet()) {
try { try {
Class<?> clazz = Class.forName((String) obj); Class<?> clazz = Class.forName((String) obj);

View file

@ -23,8 +23,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Configuration;
import org.hibernate.impl.SessionFactoryImpl; import org.hibernate.internal.SessionFactoryImpl;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
@ -39,6 +39,7 @@ import com.raytheon.uf.common.status.UFStatus;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Apr 15, 2013 1693 djohnson Initial creation * Apr 15, 2013 1693 djohnson Initial creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -63,7 +64,7 @@ public class EbxmlPostgresValidationStrategy implements
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean isDbValid(AnnotationConfiguration aConfig, public boolean isDbValid(Configuration aConfig,
SessionFactory sessionFactory) { SessionFactory sessionFactory) {
statusHandler.info("Verifying RegRep database..."); statusHandler.info("Verifying RegRep database...");
final List<String> existingTables = new ArrayList<String>(); final List<String> existingTables = new ArrayList<String>();

View file

@ -20,7 +20,7 @@
package com.raytheon.uf.edex.registry.ebxml.dao; package com.raytheon.uf.edex.registry.ebxml.dao;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Configuration;
/** /**
* Database validation strategy. * Database validation strategy.
@ -32,6 +32,7 @@ import org.hibernate.cfg.AnnotationConfiguration;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Apr 15, 2013 1693 djohnson Initial creation * Apr 15, 2013 1693 djohnson Initial creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -51,7 +52,7 @@ public interface IEbxmlDatabaseValidationStrategy {
* the session factory * the session factory
* @return true if valid * @return true if valid
*/ */
boolean isDbValid(AnnotationConfiguration aConfig, boolean isDbValid(Configuration aConfig,
SessionFactory sessionFactory); SessionFactory sessionFactory);
} }

View file

@ -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 * 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/11/2014 3011 bphillip Changed merge to not delete unused slots
* 4/21/2014 2992 dhladky General list of Registry server nodes. * 4/21/2014 2992 dhladky General list of Registry server nodes.
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -89,7 +90,7 @@ public class RegistryObjectDao extends
public void merge(RegistryObjectType newObject, public void merge(RegistryObjectType newObject,
RegistryObjectType existingObject) { RegistryObjectType existingObject) {
newObject.setId(existingObject.getId()); newObject.setId(existingObject.getId());
template.merge(newObject); getCurrentSession().merge(newObject);
} }
/** /**
@ -168,7 +169,7 @@ public class RegistryObjectDao extends
* The persistent object to delete * The persistent object to delete
*/ */
public void deleteWithoutMerge(RegistryObjectType obj) { public void deleteWithoutMerge(RegistryObjectType obj) {
this.template.delete(obj); getCurrentSession().delete(obj);
} }
public void deleteObjectWithoutDeletingChildren(RegistryObjectType obj) public void deleteObjectWithoutDeletingChildren(RegistryObjectType obj)

View file

@ -26,7 +26,6 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.criterion.Property; import org.hibernate.criterion.Property;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; 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 * 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 * 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 * 2/13/2014 2769 bphillip Added read only flags to query methods
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -245,7 +245,7 @@ public abstract class RegistryObjectTypeDao<ENTITY extends RegistryObjectType>
@Override @Override
public void setSessionFactory(SessionFactory sessionFactory) { public void setSessionFactory(SessionFactory sessionFactory) {
template = new HibernateTemplate(sessionFactory); this.sessionFactory = sessionFactory;
} }
@Override @Override

View file

@ -43,6 +43,7 @@ import com.raytheon.uf.edex.registry.ebxml.services.query.QueryConstants;
* 7/11/2013 1707 bphillip Initial implementation * 7/11/2013 1707 bphillip Initial implementation
* 7/29/2013 2191 bphillip Modified method to get orphaned slots * 7/29/2013 2191 bphillip Modified method to get orphaned slots
* 12/2/2013 1829 bphillip Changed how orphans are purged * 12/2/2013 1829 bphillip Changed how orphans are purged
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* </pre> * </pre>
* *
* @author bphillip * @author bphillip
@ -84,13 +85,15 @@ public class SlotTypeDao extends SessionManagedDao<String, SlotType> {
public void deleteBySlotId(String id) { public void deleteBySlotId(String id) {
SlotType slot = this.getById(id); SlotType slot = this.getById(id);
if (slot != null) { if (slot != null) {
this.template.delete(slot); getCurrentSession().delete(slot);
} }
} }
public void deleteBySlotId(Collection<String> ids){ public void deleteBySlotId(Collection<String> ids){
template.deleteAll(createCriteria().add( for(Object obj: createCriteria().add(
Property.forName(QueryConstants.ID).in(ids)) Property.forName(QueryConstants.ID).in(ids))
.list()); .list()){
getCurrentSession().delete(obj);
}
} }
} }

View file

@ -44,6 +44,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
* 3/13/2013 1082 bphillip Initial creation * 3/13/2013 1082 bphillip Initial creation
* 9/5/2013 1538 bphillip Added eagerLoadAll method * 9/5/2013 1538 bphillip Added eagerLoadAll method
* 2/13/2014 2769 bphillip Added read only flags to query methods * 2/13/2014 2769 bphillip Added read only flags to query methods
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *
@ -78,8 +79,7 @@ public class SubscriptionDao extends RegistryObjectTypeDao<SubscriptionType> {
*/ */
@Transactional(propagation = Propagation.REQUIRED, readOnly = true) @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
public List<SubscriptionType> eagerLoadAll() throws EbxmlRegistryException { public List<SubscriptionType> eagerLoadAll() throws EbxmlRegistryException {
List<SubscriptionType> subs = this.template List<SubscriptionType> subs = super.loadAll();
.loadAll(SubscriptionType.class);
for (SubscriptionType sub : subs) { for (SubscriptionType sub : subs) {
try { try {
/* /*

View file

@ -71,7 +71,7 @@
<filter> <filter>
<filter-name>hibernateFilter</filter-name> <filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
<init-param> <init-param>
<param-name>singleSession</param-name> <param-name>singleSession</param-name>
<param-value>true</param-value> <param-value>true</param-value>

View file

@ -43,7 +43,7 @@ import org.hibernate.criterion.Disjunction;
import org.hibernate.criterion.Junction; import org.hibernate.criterion.Junction;
import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions; 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.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
@ -64,6 +64,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Apr 22, 2011 bclement Initial creation * Apr 22, 2011 bclement Initial creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *

View file

@ -42,8 +42,8 @@ import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Disjunction; import org.hibernate.criterion.Disjunction;
import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernatespatial.criterion.SpatialRelateExpression; import org.hibernate.spatial.criterion.SpatialRelateExpression;
import org.hibernatespatial.criterion.SpatialRestrictions; import org.hibernate.spatial.criterion.SpatialRestrictions;
import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.edex.ogc.common.db.SQLParamRestriction; import com.raytheon.uf.edex.ogc.common.db.SQLParamRestriction;
@ -73,6 +73,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 17, 2012 bclement Initial creation * Oct 17, 2012 bclement Initial creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *

View file

@ -29,7 +29,7 @@ import net.opengis.filter.v_1_1_0.FilterType;
import org.geotools.geometry.jts.JTS; import org.geotools.geometry.jts.JTS;
import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Criterion;
import org.hibernatespatial.criterion.SpatialRestrictions; import org.hibernate.spatial.criterion.SpatialRestrictions;
import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeature;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
@ -62,6 +62,7 @@ import com.vividsolutions.jts.geom.Polygon;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Apr 29, 2011 bclement Initial creation * Apr 29, 2011 bclement Initial creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *

View file

@ -26,8 +26,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order; import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections; import org.hibernate.criterion.Projections;
@ -55,6 +55,7 @@ import com.raytheon.uf.edex.wfs.request.SortBy;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* May 9, 2012 bclement Initial creation * May 9, 2012 bclement Initial creation
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* *
* </pre> * </pre>
* *

View file

@ -9,7 +9,6 @@ import org.hibernate.Criteria;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback; 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. * 08/14/2013 T989 qzhou Initial creation.
* 03/13/2014 sgurung Added method purgeDataByRefTime() * 03/13/2014 sgurung Added method purgeDataByRefTime()
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* </pre> * </pre>
* *
* @author qzhou * @author qzhou
@ -63,8 +63,7 @@ public class GeoMagAvgDao extends CoreDao {
return (List<GeoMagAvg>) txTemplate.execute(new TransactionCallback() { return (List<GeoMagAvg>) txTemplate.execute(new TransactionCallback() {
@Override @Override
public Object doInTransaction(TransactionStatus status) { public Object doInTransaction(TransactionStatus status) {
HibernateTemplate ht = getHibernateTemplate(); Session sess = getCurrentSession();
Session sess = ht.getSessionFactory().getCurrentSession();
Criteria crit = sess.createCriteria(GeoMagAvg.class); Criteria crit = sess.createCriteria(GeoMagAvg.class);
Criterion where1 = Restrictions.eq("stationCode", stationCode); Criterion where1 = Restrictions.eq("stationCode", stationCode);
crit.add(where1); crit.add(where1);
@ -82,8 +81,7 @@ public class GeoMagAvgDao extends CoreDao {
return (List<GeoMagAvg>) txTemplate.execute(new TransactionCallback() { return (List<GeoMagAvg>) txTemplate.execute(new TransactionCallback() {
@Override @Override
public Object doInTransaction(TransactionStatus status) { public Object doInTransaction(TransactionStatus status) {
HibernateTemplate ht = getHibernateTemplate(); Session sess = getCurrentSession();
Session sess = ht.getSessionFactory().getCurrentSession();
Criteria crit = sess.createCriteria(GeoMagAvg.class); Criteria crit = sess.createCriteria(GeoMagAvg.class);
Criterion where1 = Restrictions.eq("stationCode", stationCode); Criterion where1 = Restrictions.eq("stationCode", stationCode);
crit.add(where1); crit.add(where1);

View file

@ -9,7 +9,6 @@ import org.hibernate.Criteria;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback; 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. * 08/14/2013 T989 qzhou Initial creation.
* 03/03/2014 #1110 qzhou Added method getRangeK1min(), Cleaned code * 03/03/2014 #1110 qzhou Added method getRangeK1min(), Cleaned code
* 03/13/2014 sgurung Added method purgeDataByRefTime() * 03/13/2014 sgurung Added method purgeDataByRefTime()
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* </pre> * </pre>
* *
* @author qzhou * @author qzhou
@ -55,9 +55,7 @@ public class GeoMagK1minDao extends CoreDao {
.execute(new TransactionCallback() { .execute(new TransactionCallback() {
@Override @Override
public Object doInTransaction(TransactionStatus status) { public Object doInTransaction(TransactionStatus status) {
HibernateTemplate ht = getHibernateTemplate(); Session sess = getCurrentSession();
Session sess = ht.getSessionFactory()
.getCurrentSession();
Criteria crit = sess.createCriteria(GeoMagK1min.class); Criteria crit = sess.createCriteria(GeoMagK1min.class);
Criterion where1 = Restrictions.eq("stationCode", Criterion where1 = Restrictions.eq("stationCode",
stationCode); stationCode);
@ -80,9 +78,7 @@ public class GeoMagK1minDao extends CoreDao {
.execute(new TransactionCallback() { .execute(new TransactionCallback() {
@Override @Override
public Object doInTransaction(TransactionStatus status) { public Object doInTransaction(TransactionStatus status) {
HibernateTemplate ht = getHibernateTemplate(); Session sess = getCurrentSession();
Session sess = ht.getSessionFactory()
.getCurrentSession();
Criteria crit = sess.createCriteria(GeoMagK1min.class); Criteria crit = sess.createCriteria(GeoMagK1min.class);
Criterion where1 = Restrictions.eq("stationCode", Criterion where1 = Restrictions.eq("stationCode",
stationCode); stationCode);

View file

@ -9,7 +9,6 @@ import org.hibernate.Criteria;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback; 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. * 08/14/2013 T989 qzhou Initial creation.
* 03/13/2014 sgurung Added method purgeDataByRefTime() * 03/13/2014 sgurung Added method purgeDataByRefTime()
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* </pre> * </pre>
* *
* @author qzhou * @author qzhou
@ -52,8 +52,7 @@ public class GeoMagK3hrDao extends CoreDao {
return (List<GeoMagK3hr>) txTemplate.execute(new TransactionCallback() { return (List<GeoMagK3hr>) txTemplate.execute(new TransactionCallback() {
@Override @Override
public Object doInTransaction(TransactionStatus status) { public Object doInTransaction(TransactionStatus status) {
HibernateTemplate ht = getHibernateTemplate(); Session sess = getCurrentSession();
Session sess = ht.getSessionFactory().getCurrentSession();
Criteria crit = sess.createCriteria(GeoMagK3hr.class); Criteria crit = sess.createCriteria(GeoMagK3hr.class);
Criterion where1 = Restrictions.eq("stationCode", stationCode); Criterion where1 = Restrictions.eq("stationCode", stationCode);
crit.add(where1); crit.add(where1);
@ -73,8 +72,7 @@ public class GeoMagK3hrDao extends CoreDao {
return (List<GeoMagK3hr>) txTemplate.execute(new TransactionCallback() { return (List<GeoMagK3hr>) txTemplate.execute(new TransactionCallback() {
@Override @Override
public Object doInTransaction(TransactionStatus status) { public Object doInTransaction(TransactionStatus status) {
HibernateTemplate ht = getHibernateTemplate(); Session sess = getCurrentSession();
Session sess = ht.getSessionFactory().getCurrentSession();
Criteria crit = sess.createCriteria(GeoMagK3hr.class); Criteria crit = sess.createCriteria(GeoMagK3hr.class);
Criterion where1 = Restrictions.eq("stationCode", stationCode); Criterion where1 = Restrictions.eq("stationCode", stationCode);
crit.add(where1); crit.add(where1);

View file

@ -16,7 +16,8 @@ Require-Bundle: com.raytheon.edex.common;bundle-version="1.11.17",
javax.persistence;bundle-version="1.0.0", javax.persistence;bundle-version="1.0.0",
org.apache.commons.codec;bundle-version="1.3.0", org.apache.commons.codec;bundle-version="1.3.0",
edu.wisc.ssec.mcidas;bundle-version="1.0.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, Export-Package: gov.noaa.nws.ncep.common.dataplugin.mcidas,
gov.noaa.nws.ncep.common.dataplugin.mcidas.dao, gov.noaa.nws.ncep.common.dataplugin.mcidas.dao,
gov.noaa.nws.ncep.common.dataplugin.mcidas.fixed gov.noaa.nws.ncep.common.dataplugin.mcidas.fixed

View file

@ -198,7 +198,7 @@ public class McidasMapCoverage extends PersistableDataObject implements
/** The map coverage */ /** The map coverage */
@Column(name = "the_geom") @Column(name = "the_geom")
@Type(type = "org.hibernatespatial.GeometryUserType") @Type(type = "org.hibernate.spatial.GeometryType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class) @XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement @DynamicSerializeElement
private Polygon location; private Polygon location;

View file

@ -12,7 +12,7 @@
</bean> </bean>
<bean id="ncepTxManager" <bean id="ncepTxManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="ncepSessionFactory" /> <property name="sessionFactory" ref="ncepSessionFactory" />
</bean> </bean>

View file

@ -1,20 +1,15 @@
package gov.noaa.nws.ncep.edex.common.dao; package gov.noaa.nws.ncep.edex.common.dao;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.List; import java.util.List;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import com.raytheon.edex.db.dao.DefaultPluginDao;
import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.persist.IPersistable; import com.raytheon.uf.common.dataplugin.persist.IPersistable;
import com.raytheon.uf.common.datastorage.IDataStore; 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; import com.raytheon.uf.edex.database.plugin.PluginDao;
public class NcepDefaultPluginDao extends PluginDao { public class NcepDefaultPluginDao extends PluginDao {
@ -51,8 +46,7 @@ public class NcepDefaultPluginDao extends PluginDao {
+ " plugin. EDEX will not purge data for " + " plugin. EDEX will not purge data for "
+ this.pluginName + " plugin"); + this.pluginName + " plugin");
} else { } else {
Session s = this.getHibernateTemplate().getSessionFactory() Session s = getSession();
.openSession();
Transaction tx = s.beginTransaction(); Transaction tx = s.beginTransaction();
try { try {

View file

@ -48,8 +48,7 @@ public abstract class NcepPointDataPluginDao<T extends PluginDataObject> extends
+ " plugin. EDEX will not purge data for " + " plugin. EDEX will not purge data for "
+ this.pluginName + " plugin"); + this.pluginName + " plugin");
} else { } else {
Session s = this.getHibernateTemplate().getSessionFactory() Session s = getSession();
.openSession();
Transaction tx = s.beginTransaction(); Transaction tx = s.beginTransaction();
try { try {

View file

@ -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.common.pointdata;bundle-version="1.11.8",
com.raytheon.uf.edex.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", 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, Import-Package: com.raytheon.uf.common.wmo,
com.raytheon.uf.edex.decodertools.core, com.raytheon.uf.edex.decodertools.core,
com.raytheon.uf.edex.decodertools.time, com.raytheon.uf.edex.decodertools.time,

View file

@ -1,5 +1,7 @@
package gov.noaa.nws.ncep.edex.plugin.aww.dao; 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.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
@ -9,7 +11,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hibernate.Session; 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.QueryResult;
import com.raytheon.uf.common.dataquery.db.QueryResultRow; 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.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig; import com.raytheon.uf.edex.database.dao.DaoConfig;
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwVtec;
public class AwwVtecDao extends CoreDao { public class AwwVtecDao extends CoreDao {
public AwwVtecDao() { public AwwVtecDao() {
@ -73,7 +72,7 @@ public class AwwVtecDao extends CoreDao {
try { try {
session = getSession(true); session = getSession(true);
conn = session.connection(); conn = SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection();
stmt = conn.createStatement(); stmt = conn.createStatement();
} catch (SQLException e) { } catch (SQLException e) {