List of usage examples for org.hibernate Query setLong
@Deprecated @SuppressWarnings("unchecked") default Query<R> setLong(String name, long val)
From source file:com.ikon.dao.MailAccountDAO.java
License:Open Source License
/** * Find by pk/* w ww . j a v a 2 s . c om*/ */ public static MailAccount findByPk(long maId) throws DatabaseException { log.debug("findByPk({})", maId); String qs = "from MailAccount ma where ma.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setLong("id", maId); MailAccount ret = (MailAccount) q.setMaxResults(1).uniqueResult(); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.OmrDAO.java
License:Open Source License
/** * Find by pk//from w ww .ja v a 2 s . c o m */ public Omr findByPk(long omId) throws DatabaseException { log.debug("findByPk({})", omId); String qs = "from Omr om where om.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setLong("id", omId); Omr ret = (Omr) q.setMaxResults(1).uniqueResult(); initializeOMR(ret); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.OmrDAO.java
License:Open Source License
/** * getProperties//from w ww . jav a 2s . c o m */ @SuppressWarnings("unchecked") public List<String> getProperties(long omId) throws DatabaseException { log.debug("getProperties({})", omId); String qs = "select om.properties from Omr om where om.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setLong("id", omId); List<String> ret = q.list(); log.debug("getProperties: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.ProfileDAO.java
License:Open Source License
/** * Find by pk//from w w w. j a v a 2s . c o m */ public static Profile findByPk(long upId) throws DatabaseException { log.debug("findByPk({})", upId); String qs = "from Profile prf where prf.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setLong("id", upId); Profile ret = (Profile) q.setMaxResults(1).uniqueResult(); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.QueryParamsDAO.java
License:Open Source License
/** * Find by pk/*from w ww .j a v a2 s .c om*/ */ public static QueryParams findByPk(long qpId) throws DatabaseException { log.debug("findByPk({})", qpId); String qs = "from QueryParams qp where qp.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setLong("id", qpId); QueryParams ret = (QueryParams) q.setMaxResults(1).uniqueResult(); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.ReportDAO.java
License:Open Source License
/** * Find by pk//from www . j ava 2 s . c o m */ public static Report findByPk(long rpId) throws DatabaseException { log.debug("findByPk({})", rpId); String qs = "from Report rp where rp.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setLong("id", rpId); Report ret = (Report) q.setMaxResults(1).uniqueResult(); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.TwitterAccountDAO.java
License:Open Source License
/** * Find by pk/* w ww . ja v a 2s . co m*/ */ public static TwitterAccount findByPk(long taId) throws DatabaseException { log.debug("findByPk({})", taId); String qs = "from TwitterAccount ta where ta.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setLong("id", taId); TwitterAccount ret = (TwitterAccount) q.setMaxResults(1).uniqueResult(); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.knowbout.epg.entities.Schedule.java
License:Apache License
/** *///from ww w .j av a2 s . c om public static NetworkSchedule selectByTimeAndNetwork(String lineup, Date date, long networkId) { Session session = HibernateUtil.currentSession(); Query query = session.getNamedQuery("Schedule.getNowPlaying"); query.setTimestamp("currentTime", date); query.setLong("network", networkId); query.setString("lineup", lineup); NetworkSchedule sked = (NetworkSchedule) query.uniqueResult(); return sked; }
From source file:com.lxd.server.dao.impl.FileDaoImpl.java
License:Open Source License
@Override public boolean queryByMd5AndLength(String md5, Long length) { String hsql = "from File as file where file.md5 = :md5 and file.length = :length"; Query query = HibernateUtil.getSessionFactory().getCurrentSession().createQuery(hsql); query.setString("md5", md5); query.setLong("length", length); return !query.list().isEmpty(); }
From source file:com.medigy.persist.model.contact.TestContactMechanism.java
License:Open Source License
public void testPhoneNumber() { final Calendar cal = new GregorianCalendar(); cal.set(1970, 1, 1);/*from www . j a v a 2 s.c o m*/ final Session session = openSession(); final Transaction transaction = session.beginTransaction(); final PhoneNumber phoneNumber = new PhoneNumber(); phoneNumber.setAreaCode("703"); phoneNumber.setNumberValue("1234567"); final PhoneNumber phoneNumber2 = new PhoneNumber(); phoneNumber2.setAreaCode("703"); phoneNumber2.setNumberValue("1234567"); final Country country = new Country(); country.setCountryName("Serenity"); country.setIsoThreeDigitCode("123"); country.setIsoThreeLetterCode("ABC"); country.setIsoTwoLetterCode("AB"); final State state = new State(); state.setStateName("Firefly"); state.setStateAbbreviation("FF"); final PostalCode zip = new PostalCode(); zip.setCodeValue("00000"); zip.setParentState(state); state.addPostalCode(zip); state.setParentCountry(country); country.addState(state); final City city = new City(); city.setCityName("Acme City"); city.setParentState(state); state.addCity(city); session.save(country); final PostalAddress address = new PostalAddress(); address.setAddress1("123 Acme Street"); address.setCity(city); address.setState(state); address.setPostalCode(zip); final Person johnDoe = new Person(); johnDoe.setLastName("Doe"); johnDoe.setFirstName("John"); johnDoe.addGender(GenderType.Cache.MALE.getEntity()); johnDoe.setBirthDate(cal.getTime()); johnDoe.addPartyContactMechanism(phoneNumber, ContactMechanismPurposeType.Cache.HOME_PHONE.getEntity()); johnDoe.addPartyContactMechanism(address, ContactMechanismPurposeType.Cache.HOME_ADDRESS.getEntity()); johnDoe.addEthnicity(EthnicityType.Cache.CAUCASIAN.getEntity()); johnDoe.addEthnicity(EthnicityType.Cache.NATIVE_AMERICAN.getEntity()); johnDoe.addEthnicity(EthnicityType.Cache.HISPANIC.getEntity()); final Person ryanHackett = new Person(); ryanHackett.setLastName("Hackett"); ryanHackett.setFirstName("Ryan"); ryanHackett.addGender(GenderType.Cache.MALE.getEntity()); ryanHackett.setBirthDate(cal.getTime()); ryanHackett.addPartyContactMechanism(phoneNumber2, ContactMechanismPurposeType.Cache.HOME_PHONE.getEntity()); session.save(phoneNumber); session.save(phoneNumber2); session.save(address); session.save(johnDoe); session.save(ryanHackett); transaction.commit(); session.close(); final Session session2 = openSession(); final Query query = session2.createQuery("from Person person " + "left join fetch person.personIdentifiers " + "left join fetch person.ethnicities " + "left join fetch person.insurancePolicies " + "left join fetch person.maritalStatuses " + "left join fetch person.partyContactMechanisms as contacts " + "left join fetch contacts.purposes " + "WHERE person.partyId = :patientId"); query.setLong("patientId", johnDoe.getPartyId()); final Person patient = (Person) query.uniqueResult(); session.close(); assertThat(patient.getPartyContactMechanisms().size(), eq(2)); final List<PartyContactMechanism> phoneNumbers = patient.getPhoneNumbers(); final List<PartyContactMechanism> addresses = patient.getAddresses(); assertThat(phoneNumbers.size(), eq(1)); assertThat(addresses.size(), eq(1)); assertThat(phoneNumbers.get(0).getPurposes().size(), eq(1)); assertThat(addresses.get(0).getPurposes().size(), eq(1)); }