List of usage examples for org.hibernate Query setLong
@Deprecated @SuppressWarnings("unchecked") default Query<R> setLong(String name, long val)
From source file:com.medigy.service.impl.contact.ContactMechanismFacadeImpl.java
License:Open Source License
public List<PostalAddress> listPostalAddresses(final Long partyId) { final ContactMechanismType postalAddressType = ContactMechanismType.Cache.POSTAL_ADDRESS.getEntity(); final Query query = getSession() .createQuery("select address from PostalAddress address, PartyContactMechanism pcm where " + "address.id = pcm.contactMechanism.id and " + "pcm.contactMechanism.type.code = ? and " + "pcm.party.id = ?"); query.setString(0, postalAddressType.getCode()); query.setLong(1, partyId); List list = query.list();//from ww w . j a v a2s. c o m List<PostalAddress> addresses = new ArrayList<PostalAddress>(list.size()); this.convert(PostalAddress.class, list, addresses); return addresses; }
From source file:com.medigy.service.impl.contact.ContactMechanismFacadeImpl.java
License:Open Source License
public List<PhoneNumber> listPhoneNumbers(final Long partyId) { final ContactMechanismType phoneType = ContactMechanismType.Cache.PHONE.getEntity(); final Query query = getSession() .createQuery("select phone from PhoneNumber phone, PartyContactMechanism pcm where " + "phone.id = pcm.contactMechanism.id and " + "pcm.contactMechanism.type.code = ? and " + "pcm.party.id = ?"); query.setString(0, phoneType.getCode()); query.setLong(1, partyId); List list = query.list();/*w w w. ja v a 2s. c o m*/ List<PhoneNumber> phoneList = new ArrayList<PhoneNumber>(list.size()); this.convert(PhoneNumber.class, list, phoneList); return phoneList; }
From source file:com.medigy.service.impl.contact.ContactMechanismFacadeImpl.java
License:Open Source License
public List<ElectronicAddress> listEmails(final Long partyId) { final ContactMechanismType emailType = ContactMechanismType.Cache.EMAIL_ADDRESS.getEntity(); final Query query = getSession() .createQuery("select address from ElectronicAddress address, PartyContactMechanism pcm where " + "address.id = pcm.contactMechanism.id and " + "pcm.contactMechanism.type.code = ? and " + "pcm.party.id = ?"); query.setString(0, emailType.getCode()); query.setLong(1, partyId); List list = query.list();/*w w w . j ava 2 s . c om*/ List<ElectronicAddress> emailList = new ArrayList<ElectronicAddress>(list.size()); this.convert(ElectronicAddress.class, list, emailList); return emailList; }
From source file:com.medigy.service.impl.insurance.InsurancePolicyFacadeImpl.java
License:Open Source License
public InsurancePolicy getInsurancePolicy(final Long personId, final BillSequenceType sequenceType) { final Query query = getSession() .createQuery("from InsurancePolicy policy where policy.insuredPerson.id = ? " + "and policy.billSequenceType.code = ?"); query.setLong(0, personId); query.setString(1, sequenceType.getCode()); final InsurancePolicy policy = (InsurancePolicy) query.uniqueResult(); return policy; }
From source file:com.medigy.service.impl.insurance.InsurancePolicyFacadeImpl.java
License:Open Source License
public List<InsurancePolicy> listInsurancePolicies(final Long personId) { final Query query = getSession() .createQuery("from InsurancePolicy policy where policy.insuredPerson.id = ? "); query.setLong(0, personId); List list = query.list();//from w w w . j a va 2 s .c o m List<InsurancePolicy> policies = new ArrayList<InsurancePolicy>(list.size()); convert(InsurancePolicy.class, list, policies); return policies; }
From source file:com.medigy.service.impl.insurance.InvoiceFacadeImpl.java
License:Open Source License
public Invoice getInvoiceById(final Long invoiceId) { final Query query = getSession().createQuery("from Invoice invoice where invoice.id = ? "); return (Invoice) query.setLong(0, invoiceId).uniqueResult(); }
From source file:com.medigy.service.impl.person.PatientWorklistServiceImpl.java
License:Open Source License
private Map<Long, Float> getPatientBalance(final PatientWorklistParameters parameters) { // TODO: There is no claimType in INVOICE. Need to re-do the patient balance query final Query query = getSession().createQuery(PATIENT_BALANCE_HQL); final List<Long> idList = new ArrayList<Long>(); for (InvoiceStatusType.Cache cache : excludeStatusList) idList.add(cache.getEntity().getSystemId()); query.setParameterList("excludeStatusList", idList); query.setLong("selfpayClaimType", ClaimType.Cache.SELFPAY.getEntity().getClaimTypeId()); final Map<Long, Float> balanceMap = new HashMap<Long, Float>(); final List list = query.list(); for (Object rowObject : list) { if (rowObject instanceof Object[]) { final Object[] columnValues = (Object[]) rowObject; balanceMap.put((Long) columnValues[0], (Float) columnValues[1]); }/*from ww w. j a v a 2 s . c o m*/ } return balanceMap; }
From source file:com.medigy.service.impl.util.ReferenceEntityFacadeImpl.java
License:Open Source License
public CustomReferenceEntity getCustomReferenceEntity(final Class customReferenceEntityClass, final String code, final Long partyId) { if (!CustomReferenceEntity.class.isAssignableFrom(customReferenceEntityClass)) return null; try {/*from w ww . ja v a 2s . c om*/ Query query = null; if (partyId == null) { query = getSession().createQuery( "from " + customReferenceEntityClass.getName() + " where " + "code = ? and party.id = ?"); query.setString(0, code); query.setLong(1, Party.Cache.SYS_GLOBAL_PARTY.getEntity().getPartyId()); return (CustomReferenceEntity) query.uniqueResult(); } else { query = getSession().createQuery("from " + customReferenceEntityClass.getName() + " where " + "code = ? and (party.id = ? or party.id = ?)"); query.setString(0, code); query.setLong(1, partyId); query.setLong(2, Party.Cache.SYS_GLOBAL_PARTY.getEntity().getPartyId()); return (CustomReferenceEntity) query.uniqueResult(); } } catch (Exception e) { log.error(ExceptionUtils.getStackTrace(e)); return null; } }
From source file:com.mimp.hibernate.HiberFamilia.java
public ArrayList<Grupo> listaGruposDeTaller(long idTaller) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();// w w w .j av a 2 s . c om ArrayList<Grupo> allGrupos = new ArrayList(); String hql = "From Grupo G where G.taller = :idT order by G.idgrupo asc"; Query query = session.createQuery(hql); query.setLong("idT", idTaller); List listaGrupos = query.list(); for (Iterator iter2 = listaGrupos.iterator(); iter2.hasNext();) { Grupo temp2 = (Grupo) iter2.next(); String hql3 = "From Turno2 T where T.grupo = :idG order by T.idturno2 asc"; query = session.createQuery(hql3); query.setLong("idG", temp2.getIdgrupo()); List listaT2 = query.list(); Set<Turno2> allTurno2 = new LinkedHashSet<>(); for (Iterator iter3 = listaT2.iterator(); iter3.hasNext();) { Turno2 temp3 = (Turno2) iter3.next(); String hql4 = "From Reunion R where R.turno2 = :idT order by R.fecha ASC"; query = session.createQuery(hql4); query.setLong("idT", temp3.getIdturno2()); List reuniones = query.list(); Set<Reunion> reunions = new LinkedHashSet<>(); for (Iterator iter4 = reuniones.iterator(); iter4.hasNext();) { Reunion reu = (Reunion) iter4.next(); reunions.add(reu); } temp3.setReunions(reunions); allTurno2.add(temp3); } temp2.setTurno2s(allTurno2); allGrupos.add(temp2); } // String hql = "From Grupo G WHERE G.taller = :id order by G.idgrupo asc"; // Query query = session.createQuery(hql); // query.setLong("id", idTaller); // List grupos = query.list(); // ArrayList<Grupo> allGrupos = new ArrayList(); // for (Iterator iter = grupos.iterator(); iter.hasNext();) { // Grupo temp = (Grupo) iter.next(); // Hibernate.initialize(temp.getTurno2s()); // Set<Turno2> allT2 = new HashSet<Turno2>(0); // for (Turno2 t2 : temp.getTurno2s()) { // Hibernate.initialize(t2.getReunions()); // allT2.add(t2); // } // temp.setTurno2s(allT2); // allGrupos.add(temp); // } return allGrupos; }
From source file:com.mimp.hibernate.HiberFamilia.java
public ArrayList<Reunion> listaReunionesTurno2(long idTurno2) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();// ww w. j a v a2 s. c om String hql = "From Reunion R WHERE R.turno2 = :id order by R.fecha asc"; Query query = session.createQuery(hql); query.setLong("id", idTurno2); List reuniones = query.list(); ArrayList<Reunion> allReuniones = new ArrayList(); for (Iterator iter = reuniones.iterator(); iter.hasNext();) { Reunion temp = (Reunion) iter.next(); Hibernate.initialize(temp.getAsistenciaFRs()); allReuniones.add(temp); } return allReuniones; }