41 lines
1.2 KiB
Plaintext
Executable File
41 lines
1.2 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.Tgeneprovince;
|
|
import com.fp.armas.portal.util.RegistroException;
|
|
|
|
/**
|
|
* Objeto de acceso a datos de la tabla {@link Tgeneprovince}
|
|
* @author dcruz
|
|
*
|
|
*/
|
|
public class ProvinciaDao extends GenericDaoImpl<Tgeneprovince> {
|
|
|
|
public ProvinciaDao() {
|
|
super(Tgeneprovince.class);
|
|
}
|
|
|
|
/**
|
|
* Consulta todas las provincias de un pa&iiacute;s
|
|
* @param countryCode
|
|
* @return
|
|
*/
|
|
public Collection<Tgeneprovince> buscarProvinciasxPais(String countryCode) {
|
|
try {
|
|
CriteriaBuilder cb = this.getEntityManager().getCriteriaBuilder();
|
|
CriteriaQuery<Tgeneprovince> query = cb.createQuery(Tgeneprovince.class);
|
|
Root<Tgeneprovince> tgeneprovinceRoot = query.from(Tgeneprovince.class);
|
|
query.where(cb.equal(tgeneprovinceRoot.get("id").get("countrycode"), countryCode)).orderBy(cb.asc(tgeneprovinceRoot.get("description")));
|
|
return this.getEntityManager().createQuery(query).getResultList();
|
|
} catch (Throwable e) {
|
|
throw new RegistroException(e);
|
|
}
|
|
}
|
|
}
|