List of usage examples for org.hibernate Query uniqueResult
R uniqueResult();
From source file:com.Bean.PostinfoHelper.java
public int getLike(int postId) { try {/*from ww w. ja va 2s . com*/ Query q = session.createQuery("from Post where postId=:postId"); q.setParameter("postId", postId); int count = ((Post) q.uniqueResult()).getLikeCount(); return count; } catch (HibernateException e) { System.err.println(e.getMessage()); } catch (Exception e) { e.printStackTrace(); } return 0; }
From source file:com.Bean.UserinfoHelper.java
public User getUserInfo(User userinfo) { try {// w ww .j ava2 s . c o m String password = userinfo.getPassword(); Query q = session.createQuery("from User as userinfo where userinfo.uid=" + userinfo.getUid() + ""); userinfo = new User(); userinfo = (User) q.uniqueResult(); return userinfo; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.Bean.UserinfoHelper.java
public User checkUserAuth(User userinfo) { try {/*w ww . j a va 2 s . co m*/ String password = userinfo.getPassword(); Query q = session.createQuery("from User as userinfo where userinfo.username = '" + userinfo.getUsername() + "' and userinfo.password = '" + userinfo.getPassword() + "'"); userinfo = new User(); userinfo = (User) q.uniqueResult(); return userinfo; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.Bean.UserinfoHelper.java
public ContactInfo getContactinfo(int uid) { org.hibernate.Transaction tx = null; try {/*ww w .j av a 2 s . c om*/ tx = session.beginTransaction(); ContactInfo contactInfo = new ContactInfo(); Query q = session.createQuery("from ContactInfo as contactinfo where contactinfo.userId = " + uid + ""); contactInfo = (ContactInfo) q.uniqueResult(); tx.commit(); return contactInfo; } catch (HibernateException e) { System.err.println(e.getMessage()); tx.rollback(); } catch (Exception e) { System.err.println(e.getMessage()); tx.rollback(); } return null; }
From source file:com.bearingpoint.dao.impl.UserDao.java
@Override public User findByUserNamePassword(User entity) { Query query = getCurrentSession() .createQuery("from User where username= :username AND password= :password"); query.setParameter("username", entity.getUsername()); query.setParameter("password", entity.getPassword()); return (User) query.uniqueResult(); // return null; }
From source file:com.bloatit.data.DaoContribution.java
License:Open Source License
/** * Gets the money raised.// www.j a v a 2s. com * * @return the money raised */ public static BigDecimal getMoneyRaised() { final Query q = SessionManager.getNamedQuery("contribution.getMoneyRaised").setParameter("state", ContributionState.CANCELED); return (BigDecimal) q.uniqueResult(); }
From source file:com.bloatit.data.DaoContribution.java
License:Open Source License
public static BigDecimal getMoneyRaised(Date from, Date to) { final Query q = SessionManager.getNamedQuery("contribution.getMoneyRaised.byDateInterval") .setParameter("state", ContributionState.CANCELED).setDate("from", from).setDate("to", to); BigDecimal res = (BigDecimal) q.uniqueResult(); if (res == null) { return BigDecimal.ZERO; }/*from w w w .j a v a 2s .co m*/ return res; }
From source file:com.bloatit.data.DaoDescription.java
License:Open Source License
/** * Get a translation for a given locale. * //from ww w . j av a 2 s . c o m * @param locale the locale in which we want the description * @return null if no translation exists for this locale. */ public DaoTranslation getTranslation(final Language language) { final Query q = SessionManager.getNamedQuery("description.getTranslations.byLocale"); q.setString("locale", language.getCode()); q.setEntity("this", this); return (DaoTranslation) q.uniqueResult(); }
From source file:com.bloatit.data.DaoFeature.java
License:Open Source License
/** * Count open bugs.//from w w w .j a va2 s .c om * * @return the int */ public int countOpenBugs() { if (selectedOffer == null) { return 0; } final Query query = SessionManager.getNamedQuery("feature.getBugs.byNonState.size"); query.setEntity("offer", this.selectedOffer); query.setParameter("state", DaoBug.BugState.RESOLVED); return ((Long) query.uniqueResult()).intValue(); }
From source file:com.bloatit.data.DaoInvoice.java
License:Open Source License
public static BigDecimal getMaxInvoiceNumber() { final Query q = SessionManager.getNamedQuery("invoice.max_invoice_number"); return (BigDecimal) q.uniqueResult(); }