Merge "Omaha #3454 Fixing usage of getSession() to ensure proper session closure" into omaha_14.4.1
Former-commit-id:2f2eb20e61
[formerlybf7d9b31b7
] [formerly2f2eb20e61
[formerlybf7d9b31b7
] [formerlye54ebf94e5
[formerly 7306aeaa7986aa69d2c18c00d940fb2eb0624612]]] Former-commit-id:e54ebf94e5
Former-commit-id:d0d6fb1e06
[formerly870fd8efd9
] Former-commit-id:256673b52c
This commit is contained in:
commit
bbd168641c
6 changed files with 97 additions and 59 deletions
|
@ -47,6 +47,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 7/24/07 353 bphillip Initial Check in
|
||||
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
|
||||
* 10/28/2014 3454 bphillip Fix usage of getSession()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -170,7 +171,13 @@ public class RadarStationDao extends CoreDao {
|
|||
}
|
||||
crit.add(stationEq);
|
||||
Session session = getSession();
|
||||
try {
|
||||
return crit.getExecutableCriteria(session).list();
|
||||
} finally {
|
||||
if (session != null){
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.warn("Cannot execute spatial query with less than 3 points");
|
||||
return new ArrayList<RadarStation>();
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
|
|||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Mar 27, 2014 2811 skorolev Updated logger.
|
||||
* Jun 06, 2014 2061 bsteffen Extend PointDataPluginDao
|
||||
* 10/28/2014 3454 bphillip Fix usage of getSession()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -122,13 +123,14 @@ public class ACARSDao extends PointDataPluginDao<ACARSRecord> {
|
|||
* The HQL query string
|
||||
* @return The list of objects returned by the query
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public List<?> executeACARSQuery(final String hqlQuery) {
|
||||
|
||||
List<?> result = (List<?>) txTemplate
|
||||
.execute(new TransactionCallback() {
|
||||
@Override
|
||||
public List<?> doInTransaction(TransactionStatus status) {
|
||||
Query hibQuery = getSession(false)
|
||||
Query hibQuery = getCurrentSession()
|
||||
.createQuery(hqlQuery);
|
||||
// hibQuery.setCacheMode(CacheMode.NORMAL);
|
||||
// hibQuery.setCacheRegion(QUERY_CACHE_REGION);
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.raytheon.uf.edex.plugin.acarssounding.tools.ACARSSoundingTools;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 21, 2009 1939 jkorman Initial creation
|
||||
* Aug 18, 2014 3530 bclement removed warning from executeSoundingQuery()
|
||||
* 10/28/2014 3454 bphillip Fix usage of getSession()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -107,7 +108,7 @@ public class ACARSSoundingDao extends DefaultPluginDao {
|
|||
List<?> result = (List<?>) txTemplate
|
||||
.execute(new TransactionCallback<Object>() {
|
||||
public List<?> doInTransaction(TransactionStatus status) {
|
||||
Query hibQuery = getSession(false)
|
||||
Query hibQuery = getCurrentSession()
|
||||
.createQuery(hqlQuery);
|
||||
return hibQuery.list();
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* May 20, 2014 2536 bclement moved from edex.textdb to edex.plugin.text
|
||||
* Sep 18, 2014 3627 mapeters Updated deprecated {@link TimeTools} usage.
|
||||
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
|
||||
* 10/28/2014 3454 bphillip Fix usage of getSession()
|
||||
* </pre>
|
||||
*
|
||||
* @author garmendariz
|
||||
|
@ -191,9 +192,10 @@ public class StdTextProductDao extends CoreDao {
|
|||
prodId.setCccid(ccc);
|
||||
prodId.setNnnid(nnn);
|
||||
prodId.setXxxid(xxx);
|
||||
Session session = this.getSession();
|
||||
try {
|
||||
Query query = this.getSession().createQuery(
|
||||
"SELECT refTime from "
|
||||
try {
|
||||
Query query = session.createQuery("SELECT refTime from "
|
||||
+ textProduct.getClass().getSimpleName()
|
||||
+ " where prodId = :prodid");
|
||||
query.setParameter("prodid", prodId);
|
||||
|
@ -216,8 +218,7 @@ public class StdTextProductDao extends CoreDao {
|
|||
String cccid = prodId.getCccid();
|
||||
String nnnid = prodId.getNnnid();
|
||||
String xxxid = prodId.getXxxid();
|
||||
Query query = this
|
||||
.getSession()
|
||||
Query query = session
|
||||
.createQuery(
|
||||
"SELECT versionstokeep FROM TextProductInfo WHERE "
|
||||
+ "prodId.cccid = :cccid AND prodId.nnnid = :nnnid AND prodId.xxxid = :xxxid");
|
||||
|
@ -234,6 +235,11 @@ public class StdTextProductDao extends CoreDao {
|
|||
logger.error("Error verify text product info", e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (session != null) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -550,8 +556,10 @@ public class StdTextProductDao extends CoreDao {
|
|||
public long getLatestTime(AFOSProductId afosId) {
|
||||
long latestTime = 0L;
|
||||
|
||||
Session sess = null;
|
||||
|
||||
try {
|
||||
Session sess = getSession();
|
||||
sess = getSession();
|
||||
|
||||
Map<?, ?> tmp = buildCriterions(ProdCCC_ID, afosId.getCcc(),
|
||||
ProdNNN_ID, afosId.getNnn(), ProdXXX_ID, afosId.getXxx());
|
||||
|
@ -573,6 +581,10 @@ public class StdTextProductDao extends CoreDao {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Error occurred getting latest time", e);
|
||||
}finally{
|
||||
if(sess != null){
|
||||
sess.close();
|
||||
}
|
||||
}
|
||||
|
||||
return latestTime;
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Map;
|
|||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
|
||||
|
@ -57,6 +58,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
|||
* Nov 08, 2013 2361 njensen Chaged method signature of saveOrUpdate(Object)
|
||||
* May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text
|
||||
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
|
||||
* 10/28/2014 3454 bphillip Fix usage of getSession()
|
||||
* </pre>
|
||||
*
|
||||
* @author mfegan
|
||||
|
@ -110,10 +112,10 @@ public class SubscriptionDAO extends CoreDao {
|
|||
*/
|
||||
public boolean write(SubscriptionRecord record) {
|
||||
// query
|
||||
Query query = this
|
||||
.getSession()
|
||||
.createQuery(
|
||||
"from SubscriptionRecord where type = :type and trigger = :trigger and runner = :runner and script = :script and filepath = :filepath and arguments = :arguments");
|
||||
Session session = this.getSession();
|
||||
try {
|
||||
Query query = session
|
||||
.createQuery("from SubscriptionRecord where type = :type and trigger = :trigger and runner = :runner and script = :script and filepath = :filepath and arguments = :arguments");
|
||||
query.setParameter("type", record.getType());
|
||||
query.setParameter("trigger", record.getTrigger());
|
||||
query.setParameter("runner", record.getRunner());
|
||||
|
@ -126,10 +128,15 @@ public class SubscriptionDAO extends CoreDao {
|
|||
return false;
|
||||
} else {
|
||||
create(record);
|
||||
sendSubscriptionNotifyMessage(String
|
||||
.valueOf(record.getIdentifier()));
|
||||
sendSubscriptionNotifyMessage(String.valueOf(record
|
||||
.getIdentifier()));
|
||||
return true;
|
||||
}
|
||||
} finally {
|
||||
if (session != null) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -172,7 +179,7 @@ public class SubscriptionDAO extends CoreDao {
|
|||
@Override
|
||||
public List<SubscriptionRecord> doInTransaction(
|
||||
TransactionStatus status) {
|
||||
Criteria criteria = getSession().createCriteria(
|
||||
Criteria criteria = getCurrentSession().createCriteria(
|
||||
daoClass);
|
||||
return criteria.list();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.text.db.WatchWarn;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
|
@ -44,6 +45,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
|
|||
* Oct 1, 2008 1538 jkorman Added additional functionality.
|
||||
* Aug 9, 2010 3944 cjeanbap Added method, queryAllWatchWarn.
|
||||
* May 20, 2014 2536 bclement moved from edex.textdb to edex.plugin.text
|
||||
* 10/28/2014 3454 bphillip Fix usage of getSession()
|
||||
* </pre>
|
||||
*
|
||||
* @author garmendariz
|
||||
|
@ -109,8 +111,15 @@ public class WatchWarnDao extends CoreDao {
|
|||
@SuppressWarnings("unchecked")
|
||||
public List<WatchWarn> queryAllWatchWarn() {
|
||||
|
||||
Criteria criteria = getSession().createCriteria(WatchWarn.class);
|
||||
Session session = getSession();
|
||||
try{
|
||||
Criteria criteria = session.createCriteria(WatchWarn.class);
|
||||
|
||||
return criteria.list();
|
||||
} finally {
|
||||
if(session != null){
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue