net.groupbuy.dao.impl.CartDaoImpl.java Source code

Java tutorial

Introduction

Here is the source code for net.groupbuy.dao.impl.CartDaoImpl.java

Source

/*
 * 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();
    }

}