All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.evasion.plugin.travel.dao.RoadMapDAO Maven / Gradle / Ivy

There is a newer version: 2.0.0.2
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.evasion.plugin.travel.dao;

import com.evasion.dao.api.AbstractJPAGenericDAO;
import com.evasion.entity.booktravel.BookTravel;
import com.evasion.entity.booktravel.RoadMap;
import java.util.Date;
import java.util.List;
import javax.persistence.Query;

/**
 * DAO pour la manipulation des Business Object de type {@link RoadMap}.
 * @author sebastien
 */
public class RoadMapDAO extends AbstractJPAGenericDAO {

    private static final String selectRoadMapByDescendingExecutionDate = "select r "
            + "from "+RoadMap.ENTITY_NAME+" r "
            + "where r.bookTravel.id=:id "
            + "order by r.executionDateInternal desc";

    public List selectRoadMapByDescendingExecutionDate(
            final Long idBookTravel, final int maxResult) {
        Query query = getEntityManager().createQuery(selectRoadMapByDescendingExecutionDate);
        query.setParameter("id", idBookTravel);
        if (maxResult > 0) {
            query.setMaxResults(maxResult);
        }
        return query.getResultList();
    }

    private static final String getRoadMapUnderDate = "select r"
            + " from " + RoadMap.ENTITY_NAME + " r "
            + "where r." + RoadMap.BOOKTRAVEL + "." + BookTravel.ID + "=:bookTravelID "
            + "and  r." + RoadMap.EXECUTION_DATE + " BETWEEN :dateDebut and :dateFin";

    public List getRoadMapUnderDate(final Long idBookTravel, final Date dateDebut, final Date dateFin) {
        Query query = getEntityManager().createQuery(getRoadMapUnderDate);
        query.setParameter("bookTravelID", idBookTravel);
        query.setParameter("dateDebut", dateDebut);
        query.setParameter("dateFin", dateFin);
        return  query.getResultList();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy