fi.foyt.fni.persistence.dao.common.CountryDAO Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of persistence Show documentation
Show all versions of persistence Show documentation
Forge & Illusion - Persistence
package fi.foyt.fni.persistence.dao.common;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.foyt.fni.persistence.dao.GenericDAO;
import fi.foyt.fni.persistence.model.common.Country;
import fi.foyt.fni.persistence.model.common.Country_;
public class CountryDAO extends GenericDAO {
private static final long serialVersionUID = 1L;
public Country findByCode(String code) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery criteria = criteriaBuilder.createQuery(Country.class);
Root root = criteria.from(Country.class);
criteria.select(root);
criteria.where(
criteriaBuilder.equal(root.get(Country_.code), code)
);
return getSingleResult(entityManager.createQuery(criteria));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy