44 lines
1.4 KiB
Plaintext
Executable File
44 lines
1.4 KiB
Plaintext
Executable File
package com.fp.armas.portal.dao.registro;
|
|
|
|
import java.util.Collection;
|
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
import javax.persistence.criteria.Root;
|
|
|
|
import com.fp.armas.portal.dao.general.GenericDaoImpl;
|
|
import com.fp.armas.portal.model.Tgenecity;
|
|
import com.fp.armas.portal.util.RegistroException;
|
|
|
|
/**
|
|
* Objeto de acceso a datos de la tabla {@link Tgenecity}
|
|
* @author dcruz
|
|
*
|
|
*/
|
|
public class CiudadDao extends GenericDaoImpl<Tgenecity> {
|
|
|
|
public CiudadDao() {
|
|
super(Tgenecity.class);
|
|
}
|
|
|
|
/**
|
|
* Busca la ciudad en base a los criterios de busqueda ingresado
|
|
* @param countryCode
|
|
* @param provinceCode
|
|
* @param cantonCode
|
|
* @return
|
|
*/
|
|
public Collection<Tgenecity> buscarCiudad(String countryCode, String provinceCode, String cantonCode) {
|
|
try {
|
|
CriteriaBuilder cb = this.getEntityManager().getCriteriaBuilder();
|
|
CriteriaQuery<Tgenecity> query = cb.createQuery(Tgenecity.class);
|
|
Root<Tgenecity> tciudadRoot = query.from(Tgenecity.class);
|
|
query.where(cb.equal(tciudadRoot.get("id").get("countrycode"), countryCode), cb.equal(tciudadRoot.get("id").get("provincecode"), provinceCode), cb.equal(tciudadRoot.get("id").get("cantoncode"), cantonCode));
|
|
query.orderBy(cb.asc(tciudadRoot.get("description")));
|
|
return this.getEntityManager().createQuery(query).getResultList();
|
|
} catch (Throwable e) {
|
|
throw new RegistroException(e);
|
|
}
|
|
}
|
|
}
|