1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.dao.impl;
17
18 import java.sql.Timestamp;
19
20 import javax.persistence.EntityManager;
21 import javax.persistence.PersistenceContext;
22
23 import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria;
24 import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria;
25 import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria.QueryByCriteriaType;
26 import org.kuali.rice.kns.lookup.LookupResults;
27 import org.kuali.rice.kns.lookup.SelectedObjectIds;
28 import org.kuali.rice.krad.dao.PersistedLookupMetadataDao;
29 import org.kuali.rice.krad.util.KRADPropertyConstants;
30
31 public class PersistedLookupMetadataDaoJpa implements PersistedLookupMetadataDao {
32 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PersistedLookupMetadataDaoJpa.class);
33
34 @PersistenceContext
35 private EntityManager entityManager;
36
37
38
39
40 public void deleteOldLookupResults(Timestamp expirationDate) {
41 Criteria criteria = new Criteria(LookupResults.class.getName());
42 criteria.lt(KRADPropertyConstants.LOOKUP_DATE, expirationDate);
43 new QueryByCriteria(entityManager, criteria, QueryByCriteriaType.DELETE).toQuery().executeUpdate();
44 }
45
46
47
48
49 public void deleteOldSelectedObjectIds(Timestamp expirationDate) {
50 Criteria criteria = new Criteria(SelectedObjectIds.class.getName());
51 criteria.lt(KRADPropertyConstants.LOOKUP_DATE, expirationDate);
52 new QueryByCriteria(entityManager, criteria, QueryByCriteriaType.DELETE).toQuery().executeUpdate();
53 }
54
55
56
57
58 public EntityManager getEntityManager() {
59 return this.entityManager;
60 }
61
62
63
64
65 public void setEntityManager(EntityManager entityManager) {
66 this.entityManager = entityManager;
67 }
68 }