List of usage examples for javax.persistence TypedQuery setParameter
TypedQuery<X> setParameter(int position, Object value);
From source file:com.plan.proyecto.repositorios.DaoContenidoImpl.java
@Override public Contenido findMensajeByComentario(Contenido comentario) { if (comentario == null) { return null; }/*from www .jav a2 s . c o m*/ TypedQuery<Contenido> query = em.createNamedQuery("Contenido.findMensajeByComentario", Contenido.class); query.setParameter("valor", comentario); List<Contenido> listaTemp = query.getResultList(); Contenido retorno; if (listaTemp.isEmpty()) { retorno = null; } else { retorno = listaTemp.get(0); } return retorno; }
From source file:ro.allevo.fintpws.security.CustomUserDetailsService.java
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { EntityManagerFactory configEntityManagerFactory = Persistence .createEntityManagerFactory(ApiResource.PERSISTENCE_UNITNAME_CONFIG); EntityManager emc = configEntityManagerFactory.createEntityManager(); final TypedQuery<UserEntity> query = emc.createNamedQuery("UserEntity.findByUsername", UserEntity.class); final java.util.List<UserEntity> results = query.setParameter("username", username).getResultList(); if (!results.isEmpty()) { return results.get(0); }/* w ww. j av a 2 s . c o m*/ return null; }
From source file:com.deltastar.task7.core.repository.api.impl.TransitionViewRepositoryImpl.java
@Override public List<TransitionView> getTransitionListByCustomerId(int customerId) { TypedQuery<TransitionView> query = entityManager.createNamedQuery("findTransitionViewByCustomerId", TransitionView.class); query.setParameter("p_customerId", customerId); return query.getResultList(); }
From source file:com.epam.ipodromproject.repository.jpa.JPAUserRepository.java
@Override public User getUserByUsername(String username) { TypedQuery<User> query = entityManager.createNamedQuery("User.findByUsername", User.class); query.setParameter("username", username); return query.getSingleResult(); }
From source file:com.ewcms.content.particular.dao.FrontEnterpriseArticleDAO.java
public List<EnterpriseArticle> findEnterpriseArticleBySector(Long organId) { String hql = "From EnterpriseArticle As p where p.organ.id=:organId and p.release=true Order By p.published desc "; TypedQuery<EnterpriseArticle> query = this.getEntityManager().createQuery(hql, EnterpriseArticle.class); query.setParameter("organId", Integer.valueOf(organId.toString())); return query.getResultList(); }
From source file:com.ewcms.content.particular.dao.FrontEnterpriseArticleDAO.java
public List<EnterpriseArticle> findEnterpriseArticleByCode(String code) { String hql = "From EnterpriseArticle As p where p.enterpriseBasic.yyzzzch=:code and p.release=true Order By p.published desc "; TypedQuery<EnterpriseArticle> query = this.getEntityManager().createQuery(hql, EnterpriseArticle.class); query.setParameter("code", code); return query.getResultList(); }
From source file:com.ewcms.content.particular.dao.FrontEnterpriseArticleDAO.java
public List<EnterpriseArticle> findEnterpriseChannelArticleLimit(Integer channelId, Integer number) { String hql = "From EnterpriseArticle As p where p.channelId=:channelId and p.release=true Order By p.published desc limit " + number;/*from w ww. j av a 2 s . c o m*/ TypedQuery<EnterpriseArticle> query = this.getEntityManager().createQuery(hql, EnterpriseArticle.class); query.setParameter("channelId", channelId); return query.getResultList(); }
From source file:org.openmeetings.app.data.basic.dao.OmTimeZoneDaoImpl.java
public OmTimeZone getOmTimeZoneByIcal(String ical) { try {/*from w w w. java 2s . c o m*/ String hql = "select sl from OmTimeZone as sl " + "WHERE sl.ical LIKE :ical"; TypedQuery<OmTimeZone> query = em.createQuery(hql, OmTimeZone.class); query.setParameter("ical", ical); List<OmTimeZone> sList = query.getResultList(); if (sList.size() > 0) { return sList.get(0); } } catch (Exception ex2) { log.error("[getOmTimeZoneByIcal]: ", ex2); } return null; }
From source file:org.openmeetings.app.data.basic.dao.OmTimeZoneDaoImpl.java
public OmTimeZone getOmTimeZoneById(Long omtimezoneId) { try {//ww w. ja va 2 s . com String hql = "select sl from OmTimeZone as sl " + "WHERE sl.omtimezoneId = :omtimezoneId"; TypedQuery<OmTimeZone> query = em.createQuery(hql, OmTimeZone.class); query.setParameter("omtimezoneId", omtimezoneId); List<OmTimeZone> sList = query.getResultList(); if (sList.size() > 0) { return sList.get(0); } } catch (Exception ex2) { log.error("[getOmTimeZoneById]: ", ex2); } return null; }
From source file:org.terasoluna.tourreservation.domain.repository.tourinfo.TourInfoRepositoryImpl.java
protected long countSearchTourInfo(TourInfoSearchCriteria criteria) { String q = buildJpqlCount(criteria.getTourDays(), criteria.getBasePrice()); TypedQuery<Long> query = entityManager.createQuery(q, Long.class); query.setParameter("adultCount", criteria.getAdultCount()); query.setParameter("childCount", criteria.getChildCount()); query.setParameter("depDay", criteria.getDepDate()); query.setParameter("depCode", criteria.getDepCode()); query.setParameter("arrCode", criteria.getArrCode()); if (criteria.getTourDays() != 0) { query.setParameter("tourDays", criteria.getTourDays()); }/*from w w w. ja v a2 s . com*/ if (criteria.getBasePrice() != 0) { query.setParameter("basePrice", criteria.getBasePrice()); } Long tourCount = query.getSingleResult(); if (tourCount == null) { tourCount = 0L; } return tourCount; }