Package org.hibernate

Examples of org.hibernate.Query


    QuerySupport.setParameter(query, params);
    query.setFirstResult((limit.getPageNo() - 1) * limit.getPageSize())
        .setMaxResults(limit.getPageSize());
    List<T> targetList = query.list();
    String queryStr = buildCountQueryStr(query);
    Query countQuery = null;
    if (query instanceof SQLQuery) {
      countQuery = getSession().createSQLQuery(queryStr);
    } else {
      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


    session = handler.getSession();
    try {
      tx = session.beginTransaction();
      // Query q = session.createQuery("select cat.id from Category as cat");
      // List result = q.list();
      Query q = session.createQuery("from Category as cat where cat.title = :title");
      q.setParameter("title", "Another category title", Hibernate.STRING);
      List cats = q.list();
      tx.commit();
      Iterator it = cats.iterator();
      while (it.hasNext()) {
        Category c = (Category) it.next();
        System.out.println("--> " + c.getId());
View Full Code Here

   * May throw runtime HibernateException
   */
  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

    //
    if (link == null) {
      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

    throw new RuntimeException("Not implemented yet.");
  }
     
 
  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

 
  public CloudIF createCloud(String domain, int port, String path, String registerProcedure, String protocol) {
    logger.info("ChannelBuilder is creating a Persistent Cloud");
    // equality by domain, port, and path
   
    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

    return obj;
  }
 
  public TextInputIF createTextInput(String title, String description,
      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

    return null;
  }
 
  public ItemSourceIF createItemSource(String name, String location, Date timestamp) {
   
    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

    return obj;
  }
 
  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

    }
    return obj;
  }
 
  public ItemGuidIF createItemGuid(ItemIF item, String location, boolean permaLink) {
    Query query = session.createQuery("from ItemGuid as guid where guid.location = ? ");
    query.setString(0, location);
    ItemGuidIF guid = (ItemGuidIF) query.uniqueResult();
    if (guid == null) {
      guid = new ItemGuid(item, location, permaLink);
      guid.setPermaLink(permaLink);
      session.save(guid);
    }
View Full Code Here

TOP

Related Classes of org.hibernate.Query

Copyright © 2018 www.massapicom. 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.