use of org.apereo.portal.spring.tx.DialectAwareTransactional in project uPortal by Jasig.
the class JpaPortletEntityDao method getPortletEntities.
@Override
@DialectAwareTransactional(value = PostgreSQL81Dialect.class, exclude = false)
@PortalTransactionalReadOnly
@OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
public Set<IPortletEntity> getPortletEntities(IPortletDefinitionId portletDefinitionId) {
Validate.notNull(portletDefinitionId, "portletEntity can not be null");
final IPortletDefinition portletDefinition = this.portletDefinitionDao.getPortletDefinition(portletDefinitionId);
final TypedQuery<PortletEntityImpl> query = this.createCachedQuery(this.findEntitiesForDefinitionQuery);
query.setParameter(this.portletDefinitionParameter, (PortletDefinitionImpl) portletDefinition);
final List<PortletEntityImpl> portletEntities = query.getResultList();
return new HashSet<IPortletEntity>(portletEntities);
}
use of org.apereo.portal.spring.tx.DialectAwareTransactional in project uPortal by Jasig.
the class JpaPortletEntityDao method getPortletEntity.
@Override
@DialectAwareTransactional(value = PostgreSQL81Dialect.class, exclude = false)
@PortalTransactionalReadOnly
@OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
public IPortletEntity getPortletEntity(String layoutNodeId, int userId) {
Validate.notNull(layoutNodeId, "portletEntity can not be null");
/* Since portal entities mostly are retrieved in batches (for each "channel" element in user's layout), it is
* faster to retrieve all portlet entities, so that persistence framework can place them in 2nd level cache, and
* iterate over them manually instead of retrieving single portlet entity one by one. */
Set<IPortletEntity> entities = getPortletEntitiesForUser(userId);
for (IPortletEntity entity : entities) {
if (StringUtils.equals(entity.getLayoutNodeId(), layoutNodeId)) {
return entity;
}
}
return null;
}
Aggregations