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

Java tutorial

Introduction

Here is the source code for net.groupbuy.dao.impl.DepositDaoImpl.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.Collections;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

import net.groupbuy.Page;
import net.groupbuy.Pageable;
import net.groupbuy.dao.DepositDao;
import net.groupbuy.entity.Deposit;
import net.groupbuy.entity.Member;

import org.springframework.stereotype.Repository;

/**
 * Dao - 
 * 
 * @author SHOP++ Team
 * @version 3.0
 */
@Repository("depositDaoImpl")
public class DepositDaoImpl extends BaseDaoImpl<Deposit, Long> implements DepositDao {

    public Page<Deposit> findPage(Member member, Pageable pageable) {
        if (member == null) {
            return new Page<Deposit>(Collections.<Deposit>emptyList(), 0, pageable);
        }
        CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
        CriteriaQuery<Deposit> criteriaQuery = criteriaBuilder.createQuery(Deposit.class);
        Root<Deposit> root = criteriaQuery.from(Deposit.class);
        criteriaQuery.select(root);
        criteriaQuery.where(criteriaBuilder.equal(root.get("member"), member));
        return super.findPage(criteriaQuery, pageable);
    }

}