001 /**
002 * Copyright 2005-2011 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.krad.dao.impl;
017
018 import java.sql.Timestamp;
019
020 import javax.persistence.EntityManager;
021 import javax.persistence.PersistenceContext;
022
023 import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria;
024 import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria;
025 import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria.QueryByCriteriaType;
026 import org.kuali.rice.krad.bo.SessionDocument;
027 import org.kuali.rice.krad.dao.SessionDocumentDao;
028 import org.kuali.rice.krad.util.KRADPropertyConstants;
029
030 public class SessionDocumentDaoJpa implements SessionDocumentDao {
031 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SessionDocumentDaoJpa.class);
032
033 @PersistenceContext
034 private EntityManager entityManager;
035
036 /**
037 * @see org.kuali.rice.krad.dao.SessionDocumentDao#purgeAllSessionDocuments(java.sql.Timestamp)
038 */
039 public void purgeAllSessionDocuments(Timestamp expirationDate) {
040 Criteria criteria = new Criteria(SessionDocument.class.getName());
041 criteria.lt(KRADPropertyConstants.LAST_UPDATED_DATE, expirationDate);
042 new QueryByCriteria(entityManager, criteria, QueryByCriteriaType.DELETE).toQuery().executeUpdate();
043 }
044
045 /**
046 * @return the entityManager
047 */
048 public EntityManager getEntityManager() {
049 return this.entityManager;
050 }
051
052 /**
053 * @param entityManager the entityManager to set
054 */
055 public void setEntityManager(EntityManager entityManager) {
056 this.entityManager = entityManager;
057 }
058
059
060 }