com.qfix.vms.dao.impl.ToolsDaoImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.qfix.vms.dao.impl.ToolsDaoImpl.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qfix.vms.dao.impl;

/**
 *
 * @author Tishan Madhawa
 */

import com.qfix.vms.dao.AbstractDao;
import com.qfix.vms.dao.ToolsDao;
import com.qfix.vms.model.Tools;
import java.io.Serializable;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.springframework.stereotype.Repository;

@Repository("ToolsDao")
public class ToolsDaoImpl extends AbstractDao<Serializable, Tools> implements ToolsDao {
    @SuppressWarnings("unchecked")
    @Override
    public void saveTools(Tools tools) {
        persist(tools);
    }

    @Override
    public List<Tools> findAllTools() {
        Criteria criteria = createEntityCriteria().addOrder(Order.asc("ID"));
        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
        List<Tools> tools = (List<Tools>) criteria.list();
        return tools;
    }

}