Permalink
Browse files

UP-3509 Make sure EntityManager is open when doing naturalId queries

  • Loading branch information...
edalquist committed Jul 19, 2012
1 parent 6b71525 commit ae1369ae2096e7042860bb3d7476e07ee478caba
@@ -45,6 +45,7 @@
import org.jasig.portal.events.aggr.groups.AggregatedGroupMapping;
import org.jasig.portal.events.aggr.groups.AggregatedGroupMappingImpl;
import org.jasig.portal.jpa.BaseAggrEventsJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
@@ -332,6 +333,7 @@ public final void afterPropertiesSet() throws Exception {
}
@Override
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
public final T getAggregation(K key) {
final NaturalIdQuery<T> query = this.createNaturalIdQuery(this.aggregationEntityType);
query.using(BaseAggregationImpl_.dateDimension, (DateDimensionImpl)key.getDateDimension());
@@ -32,6 +32,7 @@
import org.jasig.portal.events.aggr.DateDimension;
import org.jasig.portal.events.aggr.dao.DateDimensionDao;
import org.jasig.portal.jpa.BaseAggrEventsJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.joda.time.DateMidnight;
import org.joda.time.LocalDate;
import org.springframework.dao.support.DataAccessUtils;
@@ -205,6 +206,7 @@ public DateDimension getDateDimensionById(long key) {
return dateDimension;
}
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
@Override
public DateDimension getDateDimensionByDate(DateMidnight date) {
final NaturalIdQuery<DateDimensionImpl> query = this.createNaturalIdQuery(DateDimensionImpl.class);
@@ -43,6 +43,7 @@
import org.jasig.portal.events.aggr.QuarterDetail;
import org.jasig.portal.events.aggr.dao.IEventAggregationManagementDao;
import org.jasig.portal.jpa.BaseAggrEventsJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.joda.time.DateMidnight;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.stereotype.Repository;
@@ -164,7 +165,7 @@ public void afterPropertiesSet() throws Exception {
"DELETE FROM " + QuarterDetailImpl.class.getName() + " e ";
}
-
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
@Override
public IEventAggregatorStatus getEventAggregatorStatus(final ProcessingType processingType, boolean create) {
final NaturalIdQuery<EventAggregatorStatusImpl> query = this.createNaturalIdQuery(EventAggregatorStatusImpl.class);
@@ -30,6 +30,7 @@
import org.jasig.portal.events.aggr.TimeDimension;
import org.jasig.portal.events.aggr.dao.TimeDimensionDao;
import org.jasig.portal.jpa.BaseAggrEventsJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.joda.time.LocalTime;
import org.springframework.stereotype.Repository;
@@ -84,6 +85,7 @@ public TimeDimension getTimeDimensionById(long key) {
return timeDimension;
}
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
@Override
public TimeDimension getTimeDimensionByTime(LocalTime localTime) {
final NaturalIdQuery<TimeDimensionImpl> query = this.createNaturalIdQuery(TimeDimensionImpl.class);
@@ -32,6 +32,7 @@
import org.jasig.portal.groups.ICompositeGroupService;
import org.jasig.portal.groups.IEntityGroup;
import org.jasig.portal.jpa.BaseAggrEventsJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.jasig.portal.jpa.cache.EntityManagerCache;
import org.jasig.portal.utils.cache.CacheKey;
import org.springframework.beans.factory.annotation.Autowired;
@@ -77,6 +78,7 @@ public void afterPropertiesSet() throws Exception {
});
}
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
@Override
public AggregatedGroupMapping getGroupMapping(final String groupService, final String groupName) {
final CacheKey key = CacheKey.build(this.getClass().getName(), groupService, groupName);
@@ -27,6 +27,7 @@
import javax.persistence.criteria.CriteriaQuery;
import org.jasig.portal.jpa.BaseAggrEventsJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.jasig.portal.jpa.cache.EntityManagerCache;
import org.jasig.portal.portlet.dao.IPortletDefinitionDao;
import org.jasig.portal.portlet.om.IPortletDefinition;
@@ -73,7 +74,7 @@ public void afterPropertiesSet() throws Exception {
});
}
-
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
@Override
public AggregatedPortletMapping getMappedPortletForFname(final String fname) {
final CacheKey key = CacheKey.build(this.getClass().getName(), fname);
@@ -34,6 +34,7 @@
import org.jasig.portal.jpa.BaseAggrEventsJpaDao;
import org.jasig.portal.jpa.BasePortalJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.jasig.portal.jpa.cache.EntityManagerCache;
import org.jasig.portal.utils.Tuple;
import org.jasig.portal.utils.cache.CacheKey;
@@ -97,6 +98,7 @@ public AggregatedTabMapping getMappedTabForLayoutId(String layoutNodeId) {
return getTabMapping(resolveTabName.first, resolveTabName.second);
}
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
@Override
public AggregatedTabMapping getTabMapping(final String fragmentName, final String tabName) {
final CacheKey key = CacheKey.build(this.getClass().getName(), tabName);
@@ -30,6 +30,7 @@
import org.apache.commons.lang.Validate;
import org.jasig.portal.jpa.BasePortalJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.jasig.portal.layout.dao.IStylesheetDescriptorDao;
import org.jasig.portal.layout.om.IStylesheetDescriptor;
import org.springframework.stereotype.Repository;
@@ -81,6 +82,7 @@ public IStylesheetDescriptor getStylesheetDescriptor(long id) {
return stylesheetDescriptor;
}
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
@Override
public IStylesheetDescriptor getStylesheetDescriptorByName(String name) {
final NaturalIdQuery<StylesheetDescriptorImpl> query = this.createNaturalIdQuery(StylesheetDescriptorImpl.class);
@@ -31,6 +31,7 @@
import javax.persistence.criteria.Root;
import org.jasig.portal.jpa.BasePortalJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.jasig.portal.permission.IPermissionActivity;
import org.jasig.portal.permission.IPermissionOwner;
import org.jasig.portal.permission.dao.IPermissionOwnerDao;
@@ -90,6 +91,7 @@ public IPermissionOwner getPermissionOwner(long id){
return getEntityManager().find(PermissionOwnerImpl.class, id);
}
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
@Override
public IPermissionOwner getPermissionOwner(String fname){
final NaturalIdQuery<PermissionOwnerImpl> query = this.createNaturalIdQuery(PermissionOwnerImpl.class);
@@ -37,6 +37,7 @@
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.time.DateUtils;
import org.jasig.portal.jpa.BasePortalJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.jasig.portal.portlet.dao.IPortletCookieDao;
import org.jasig.portal.portlet.om.IPortalCookie;
import org.jasig.portal.portlet.om.IPortletCookie;
@@ -115,6 +116,7 @@ public IPortalCookie createPortalCookie(int maxAge) {
return portalCookie;
}
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
@Override
public IPortalCookie getPortalCookie(String portalCookieValue) {
final NaturalIdQuery<PortalCookieImpl> query = this.createNaturalIdQuery(PortalCookieImpl.class);
@@ -29,6 +29,7 @@
import org.apache.commons.lang.Validate;
import org.jasig.portal.jpa.BasePortalJpaDao;
+import org.jasig.portal.jpa.OpenEntityManager;
import org.jasig.portal.portlet.dao.IPortletTypeDao;
import org.jasig.portal.portlet.om.IPortletType;
import org.springframework.stereotype.Repository;
@@ -94,7 +95,8 @@ public IPortletType getPortletType(int id) {
return this.getEntityManager().find(PortletTypeImpl.class, id);
}
- @Override
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
+ @Override
public IPortletType getPortletType(String name) {
final NaturalIdQuery<PortletTypeImpl> query = this.createNaturalIdQuery(PortletTypeImpl.class);
query.using(PortletTypeImpl_.name, name);
@@ -29,7 +29,7 @@
public class JpaVersionDao extends BasePortalJpaDao implements VersionDao {
@Override
- @OpenEntityManager(unitName=BasePortalJpaDao.PERSISTENCE_UNIT_NAME)
+ @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
public VersionImpl getVersion(String product) {
NaturalIdQuery<VersionImpl> query = this.createNaturalIdQuery(VersionImpl.class);
query.using(VersionImpl_.product, product);

0 comments on commit ae1369a

Please sign in to comment.