Java tutorial
/* * Copyright 2005-2013 shopxx.net. All rights reserved. * Support: http://www.shopxx.net * License: http://www.shopxx.net/license */ package net.groupbuy.dao.impl; import java.util.Date; import javax.persistence.FlushModeType; import net.groupbuy.dao.CartDao; import net.groupbuy.entity.Cart; import org.apache.commons.lang.time.DateUtils; import org.springframework.stereotype.Repository; /** * Dao - * * @author SHOP++ Team * @version 3.0 */ @Repository("cartDaoImpl") public class CartDaoImpl extends BaseDaoImpl<Cart, Long> implements CartDao { public void evictExpired() { String jpql = "delete from Cart cart where cart.modifyDate <= :expire"; entityManager.createQuery(jpql).setFlushMode(FlushModeType.COMMIT) .setParameter("expire", DateUtils.addSeconds(new Date(), -Cart.TIMEOUT)).executeUpdate(); } }