Java tutorial
/* * Copyright (C) 2016 Dominion Global * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.dominion.salud.mpr.negocio.repositories.integracion.impl; import com.dominion.salud.mpr.negocio.configuration.MPRConstantes; import com.dominion.salud.mpr.negocio.entities.admin.Centros; import com.dominion.salud.mpr.negocio.entities.integracion.BuzonInHis; import java.util.Date; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.apache.commons.lang3.time.DateUtils; import org.springframework.stereotype.Repository; /** * * @author jcgonzalez */ @Repository("buzonInHisRepository") public class BuzonInHisRepositoryImpl { @PersistenceContext private EntityManager entityManager; public List<BuzonInHis> findAllByIdCentro(Centros centros) { return entityManager.createQuery("from BuzonInHis where centros.idCentro = :idCentro", BuzonInHis.class) .setParameter("idCentro", centros.getIdCentro()).getResultList(); } public List<BuzonInHis> findAllByAntiguedad() { Date antiguedad = DateUtils.addDays(new Date(), (MPRConstantes._TASK_BUZON_IN_HIS_CLEAN_OLD * -1)); return entityManager.createQuery("from BuzonInHis where fechaIn < :fechaIn", BuzonInHis.class) .setParameter("fechaIn", antiguedad).getResultList(); } }