data.dao.ColorDao.java Source code

Java tutorial

Introduction

Here is the source code for data.dao.ColorDao.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 data.dao;

import data.dao.parent.Dao;
import data.entity.Color;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

/**
 *
 * @author bezdatiuzer
 */
@Repository("colorDao")
public class ColorDao extends Dao<Color> {

    @Override
    public Class getSupportedClass() {
        return Color.class;
    }

    public List<Color> findByQId(Long oldId) {
        Criteria cr = currentSession().createCriteria(getSupportedClass());
        cr.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
        cr.add(Restrictions.eq("oldId", oldId));
        return cr.list();
    }

}