Examples of uniqueResult()


Examples of org.hibernate.Query.uniqueResult()

      if (null == cntQuery) {
        Query hibernateQuery = buildHibernateQuery(limitQuery, hibernateSession);
        return hibernateQuery.list().size();
      } else {
        Query hibernateQuery = buildHibernateQuery(cntQuery, hibernateSession);
        final Number count = (Number) (hibernateQuery.uniqueResult());
        if (null == count) {
          return 0;
        } else {
          return count.intValue();
        }
View Full Code Here

Examples of org.hibernate.Query.uniqueResult()

      countQuery = getSession().createQuery(queryStr);
    }
    QuerySupport.setParameter(countQuery, params);
    // 返回结果
    return new SinglePage<T>(limit.getPageNo(), limit.getPageSize(),
        ((Number) (countQuery.uniqueResult())).intValue(), targetList);
  }

  /**
   * 构造查询记录数目的查询字符串
   *
 
View Full Code Here

Examples of org.hibernate.Query.uniqueResult()

      countQuery = getSession().createQuery(queryStr);
    }
    QuerySupport.setParameter(countQuery, params);
    // 返回结果
    return new SinglePage<T>(limit.getPageNo(), limit.getPageSize(),
        ((Number) (countQuery.uniqueResult())).intValue(), targetList);
  }

  public void saveOrUpdate(Object... entities) {
    if (null == entities) return;
    for (Object entity : entities) {
View Full Code Here

Examples of org.hibernate.Query.uniqueResult()

  public ChannelIF createChannel(Element channelElement, String title, String location) {
    ChannelIF obj = null;
    if (location != null) {
      Query query = session.createQuery("from Channel as channel where channel.locationString = ? ");
      query.setString(0, location);
      obj = (ChannelIF) query.uniqueResult();
    }
    if (obj == null) {
      obj = new Channel(channelElement, title, location);
      session.save(obj);
    } else {
View Full Code Here

Examples of org.hibernate.Query.uniqueResult()

      throw new RuntimeException("link required for item " + title + " for persistence uniqueness");
    }
   
    Query query = session.createQuery("from Item as item where item.linkString = ? ");
    query.setString(0, link.toString());
    ItemIF obj = (ItemIF) query.uniqueResult();
    if (obj == null) {
      obj = new Item(channel, title, description, link);
      if (channel != null) {
        channel.addItem(obj);
      }
View Full Code Here

Examples of org.hibernate.Query.uniqueResult()

     
 
  public ImageIF createImage(String title, URL location, URL link) {
    Query query = session.createQuery("from Image as img where img.locationString = ? ");
    query.setString(0, location.toString());
    ImageIF obj = (Image) query.uniqueResult();
    if (obj == null) {
      obj = new Image(title, location, link);
      session.save(obj);
    }
    return obj;
View Full Code Here

Examples of org.hibernate.Query.uniqueResult()

   
    Query query = session.createQuery("from Cloud as cld where cld.domain = ? and cld.port = ? and cld.path = ?");
    query.setString(0, domain);
    query.setInteger(1, port);
    query.setString(2, path);
    CloudIF obj = (CloudIF) query.uniqueResult();
    if (obj == null) {
      obj = new Cloud(domain, port, path, registerProcedure, protocol);
      session.save(obj);
    }
   
View Full Code Here

Examples of org.hibernate.Query.uniqueResult()

      String name, URL link) {
    Query query = session.createQuery("from TextInput as txt where txt.title = ? and txt.name = ? and txt.linkString = ? ");
    query.setString(0, title);
    query.setString(1, name);
    query.setString(2, link.toString());
    TextInputIF obj = (TextInput) query.uniqueResult();
    if (obj == null) {
      obj = new TextInput(title, description, name, link);
      session.save(obj);
    }
    return obj;
View Full Code Here

Examples of org.hibernate.Query.uniqueResult()

   
    Query query = session.createQuery("from ItemSource as src where src.name = ? and src.location = ? and src.timestamp = ?  ");
    query.setString(0, name);
    query.setString(1, location);
    query.setTimestamp(2, timestamp);
    ItemSourceIF obj = (ItemSourceIF) query.uniqueResult();
    if (obj == null) {
      obj = new ItemSource(null, name, location, timestamp);
      session.save(obj);
    }
    return obj;
View Full Code Here

Examples of org.hibernate.Query.uniqueResult()

 
  public ItemEnclosureIF createItemEnclosure(ItemIF item, URL location,
      String type, int length) {
    Query query = session.createQuery("from ItemEnclosure as enc where enc.item.id = ? ");
    query.setLong(0, item.getId());
    ItemEnclosureIF obj = (ItemEnclosureIF) query.uniqueResult();
    if (obj == null) {
      obj = new ItemEnclosure(item, location, type, length);
      session.save(obj);
    }
    return obj;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.