List of usage examples for javax.persistence TypedQuery getResultList
List<X> getResultList();
From source file:org.openmeetings.app.data.user.dao.UsersDaoImpl.java
/** * returns the maximum//from w w w . j a va2s .c o m * * @return */ public Long selectMaxFromUsers() { try { // get all users TypedQuery<Long> query = em .createQuery("select count(c.user_id) from Users c where c.deleted = 'false'", Long.class); List<Long> ll = query.getResultList(); log.info("selectMaxFromUsers" + ll.get(0)); return ll.get(0); } catch (Exception ex2) { log.error("[selectMaxFromUsers] ", ex2); } return null; }
From source file:org.openmeetings.app.data.flvrecord.FlvRecordingMetaDataDaoImpl.java
public List<FlvRecordingMetaData> getFlvRecordingMetaDataByRecording(Long flvRecordingId) { try {//from w w w .ja va2 s .c o m String hql = "SELECT c FROM FlvRecordingMetaData c " + "WHERE c.flvRecording.flvRecordingId = :flvRecordingId " + "AND c.deleted <> :deleted "; TypedQuery<FlvRecordingMetaData> query = em.createQuery(hql, FlvRecordingMetaData.class); query.setParameter("flvRecordingId", flvRecordingId); query.setParameter("deleted", "true"); List<FlvRecordingMetaData> flvRecordingMetaDatas = query.getResultList(); return flvRecordingMetaDatas; } catch (Exception ex2) { log.error("[getFlvRecordingMetaDataByRecording]: ", ex2); } return null; }
From source file:com.ilkgunel.hastaneotomasyonu.service.AvailableAppointmentsService.java
public Boolean[] changeRenderingStates(SaveAppointments saveAppointments) { int doctorid = 0; int uygunrandevuid = 0; if (saveAppointments != null) { doctorid = saveAppointments.getSelectedAppointment().getDoktorid(); uygunrandevuid = saveAppointments.getSelectedAppointment().getUygunrandevuid(); }//from w w w.j a va2 s .c om TypedQuery<Object[]> doctorAndTimeQuery = em.createQuery( "SELECT u.doktoradi,FUNCTION('DATE',u.tarih),u.uygunrandevuid FROM Uygunrandevular AS u WHERE u.doktorid=:doctorid ORDER BY u.tarih ASC", Object[].class); doctorAndTimeQuery.setParameter("doctorid", doctorid); doctorAndTimeList = new ArrayList<>(); doctorAndTimeList = doctorAndTimeQuery.getResultList(); TypedQuery<Randevusaatleri> query = em .createQuery("SELECT c FROM Randevusaatleri c WHERE c.doktorid=:doctorid", Randevusaatleri.class); System.out.println("Seilen Randevunun ID'si" + uygunrandevuid); query.setParameter("doctorid", uygunrandevuid); appointmentClockResults = new ArrayList<>(); appointmentClockResults = query.getResultList(); Boolean[] array = new Boolean[2]; array[0] = false; array[1] = true; return array; }
From source file:org.openmeetings.app.data.conference.PollManagement.java
public List<RoomPoll> getArchivedPollList(Long room_id) { try {//from w w w.j ava2 s .co m log.debug(" :: getPoll :: " + room_id); TypedQuery<RoomPoll> q = em.createQuery( "SELECT rp FROM RoomPoll rp WHERE rp.room.rooms_id = :room_id AND rp.archived = :archived", RoomPoll.class); q.setParameter("room_id", room_id); q.setParameter("archived", true); return q.getResultList(); } catch (NoResultException nre) { //expected } catch (Exception err) { log.error("[getPoll]", err); } return null; }
From source file:org.openmeetings.app.data.user.dao.UserContactsDaoImpl.java
public Long checkUserContacts(Long user_id, Long ownerId) { try {//from ww w. ja v a 2s .co m String hql = "select count(c.userContactId) from UserContacts c " + "where c.contact.user_id = :user_id AND c.owner.user_id = :ownerId "; TypedQuery<Long> query = em.createQuery(hql, Long.class); query.setParameter("user_id", user_id); query.setParameter("ownerId", ownerId); List<Long> ll = query.getResultList(); log.info("checkUserContacts" + ll.get(0)); return ll.get(0); } catch (Exception e) { log.error("[checkUserContacts]", e); } return null; }
From source file:ch.puzzle.itc.mobiliar.business.resourcegroup.control.ResourceTypeDomainService.java
public List<ResourceRelationTypeEntity> loadRelatedResourceTypeRelations(Integer resourceTypeId) { String sql = "select r from ResourceRelationTypeEntity r, ResourceTypeEntity t"; sql += " where r.resourceTypeA.id = :resourceTypeId"; sql += " and r.resourceTypeB.id = t.id"; sql += " order by t.id"; TypedQuery<ResourceRelationTypeEntity> query = entityManager.createQuery(sql, ResourceRelationTypeEntity.class); query.setParameter("resourceTypeId", resourceTypeId); return query.getResultList(); }
From source file:com.pingdu.dao.licenseDao.LicenseTypeDao.java
/** * /*ww w . j a va 2 s. c o m*/ * * @param entCode * @param page * @param status * @return */ public int calPage(int page) { try { String jpql = LicenseTypeSQL(page); TypedQuery query = em().createQuery(jpql, LicenseTypeReturn.class); query.setHint(QueryHints.RESULT_TYPE, ResultType.Map); // query.setParameter("entCode", entCode); // Query query=em().createQuery(jpql); int sum = (query.getResultList().size() - 1) / PublicVariable.rows + 1; return sum; } catch (Exception e) { // TODO: handle exception System.out.println("" + e.getMessage()); return 1; } }
From source file:com.fantasy.stataggregator.entities.dao.AbstractRepository.java
public List<T> findByNamedQuery(Class<T> entity, String name, Map<String, ? extends Object> parameters) { NamedQueries nq = entity.getAnnotation(NamedQueries.class); NamedQuery[] nqs = nq.value();/*from w ww .j a v a 2 s.c o m*/ String queryName = null; for (NamedQuery qn : nqs) { String qname = qn.name(); if (qname.contains(name)) { queryName = qname; break; } } List<T> results = new ArrayList(1); if (Objects.nonNull(queryName)) { TypedQuery<T> query = em.createNamedQuery(queryName, entityClass); if (Objects.nonNull(parameters) && !parameters.isEmpty()) { parameters.entrySet().stream().forEach((entry) -> { query.setParameter((String) entry.getKey(), entry.getValue()); }); } results = query.getResultList(); } return results; }
From source file:ch.puzzle.itc.mobiliar.business.shakedown.control.ShakedownTestRunner.java
public String getStrCsv() { StringBuilder sb = new StringBuilder(); TypedQuery<ShakedownStpEntity> q = entityManager.createQuery("from ShakedownStpEntity", ShakedownStpEntity.class); List<ShakedownStpEntity> stps = q.getResultList(); for (ShakedownStpEntity s : stps) { sb.append(s.getStpName()).append('\t').append(s.getVersion()).append('\n'); }//from w w w .j ava 2 s . c o m return sb.toString(); }
From source file:bq.jpa.demo.query.criteria.service.CriteriaService.java
/** * SELECT e FROM jpa_query_employee e WHERE e.name= :name *///from w ww . j a va 2 s. com @Transactional public void doParameterQuery() { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Employee> c = cb.createQuery(Employee.class); Root<Employee> e = c.from(Employee.class); // parameter, equal to ":name" ParameterExpression<String> paraName = cb.parameter(String.class, "name"); // e.name = ":name" c.select(e).where(cb.equal(e.get("name"), paraName)); // set param value TypedQuery<Employee> query = em.createQuery(c); query.setParameter("name", "employee_1"); List<Employee> result = query.getResultList(); ResultViewer.showResult(result, "criteria query : parameter query"); }