Search in sources :

Example 1 with DialectAwareTransactional

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);
}
Also used : IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) HashSet(java.util.HashSet) DialectAwareTransactional(org.apereo.portal.spring.tx.DialectAwareTransactional) OpenEntityManager(org.apereo.portal.jpa.OpenEntityManager)

Example 2 with DialectAwareTransactional

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;
}
Also used : IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) DialectAwareTransactional(org.apereo.portal.spring.tx.DialectAwareTransactional) OpenEntityManager(org.apereo.portal.jpa.OpenEntityManager)

Aggregations

OpenEntityManager (org.apereo.portal.jpa.OpenEntityManager)2 DialectAwareTransactional (org.apereo.portal.spring.tx.DialectAwareTransactional)2 HashSet (java.util.HashSet)1 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)1 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)1