⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 accountdaoimpl.java

📁 一个关于tlms的一个小程序 看看能否帮助到别人
💻 JAVA
字号:
/**
 * Created by szmx.
 * User: hliu
 * Date: 2006-4-6
 * Time: 17:58:46
 * To change this template use File | Settings | File Templates.
 */
package com.szmx.tlms.finance.dao.impl;

import com.szmx.tlms.finance.dao.AccountDAO;
import com.szmx.tlms.finance.model.Account;
import com.szmx.framework.base.dao.impl.BaseDaoImpl;
import com.szmx.framework.base.model.Pagination;
import com.szmx.framework.util.StringUtil;
import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;

import java.util.List;
import java.util.Map;


public class AccountDAOImpl extends BaseDaoImpl implements AccountDAO {

    /**
     * Get the one page's record ,There are some paramete in the paraMap
     *
     * @param paginationObj
     * @param paraMap
     * @return Pagination
     */
    public Pagination getAccounts(final Pagination paginationObj, final Map paraMap) {

        Account account = (Account) paraMap.get("searchBean");
        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Account.class);

        if (account != null) {
            if (!StringUtil.isNull(account.getLocalAccountCode1())) {
                detachedCriteria.add(Restrictions.like("localAccountCode1",
                                                       account.getLocalAccountCode1(),
                                                       MatchMode.ANYWHERE));
            }
            if (!StringUtil.isNull(account.getLocalAccountDesc1())) {
                detachedCriteria.add(Restrictions.like("localAccountDesc1",
                                                       account.getLocalAccountDesc1(),
                                                       MatchMode.ANYWHERE));
            }
            if (!StringUtil.isNull(account.getSapAccountCode())) {
                detachedCriteria.add(Restrictions.like("sapAccountCode",
                                                       account.getSapAccountCode(),
                                                       MatchMode.ANYWHERE));

            }
            if (!StringUtil.isNull(account.getSapAccountDesc())) {
                detachedCriteria.add(Restrictions.like("sapAccountDesc",
                                                       account.getSapAccountDesc(),
                                                       MatchMode.ANYWHERE));
            }
        }

        return findPageByCriteria(detachedCriteria, paginationObj);
    }

    /**
     *
     * @param param
     * @param value
     * @return Account
     */
    public Account getAccount(final String param, final String value) {
        if (StringUtil.isNull(param)) {
            return null;
        }

        return (Account) this.findBy(Account.class, param, value);
    }

    /**
     * Check that if the SAPCode has existed in the system.
     * @param account
     * @return List account list the match the query condition.
     */
    public List getAccountsBySAPCode(final Account account) {
        if (getSession() != null) {
            //Generate the Criteria object
            Criteria criteria = getSession().createCriteria(Account.class);
            criteria.add(Expression.like("sapAccountCode",
                         account.getSapAccountCode(),
                         MatchMode.EXACT));
            return criteria.list();
        }
        return null;
    }

    /**
     * Save the account to the database
     * @param account
     */
    public void saveAccount(final Account account) {
        getHibernateTemplate().saveOrUpdate(account);

    }

    /**
     * Get one account object by account id
     * @param id
     * @return Account
     */
    public Account getAccount(final Long id) {
        Account account = (Account) getHibernateTemplate().get(Account.class, id);
        return account;
    }

    /**
     * Remove the account by account id
     * @param id
     */
    public void removeAccount(final Long id) {
        getHibernateTemplate().delete(getAccount(id));
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -