com.gotour.daos.ReviewDaoImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.gotour.daos.ReviewDaoImpl.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.gotour.daos;

import com.gotour.models.Review;
import java.util.List;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

@Repository("repositoryDao")
public class ReviewDaoImpl extends GenericDaoImpl<Review> implements ReviewDao {

    public List<Review> getLast(int n) {
        String hql = "from Review r order by r.id desc";
        Query query = getSession().createQuery(hql);
        query.setMaxResults(n);
        return query.list();
    }
}