Package org.hibernate

Examples of org.hibernate.Session.createQuery()


      hql.append(" AND p.album.id=:album");
    if(month >= 190001 && month <= 209912){
      hql.append(" AND p.year = :year AND p.month = :month");
    }
    Session ssn = getSession();
    Query q = ssn.createQuery(hql.toString());
    q.setInteger("site", sid);
    if(album_id > 0)
      q.setInteger("album", album_id);
    if(month >= 190001 && month <= 209912){
      q.setInteger("year", month / 100);
View Full Code Here


      hql.append(" AND j.status=:status AND j.album.type=:album_type");
    }
       
    try{
      Session ssn = getSession();
      Query q = ssn.createQuery(hql.toString()).setCacheable(true);
      q.setTimestamp("beginTime", firstDate.getTime());
      q.setTimestamp("endTime", nextMonthFirstDate.getTime());
      q.setInteger("site", site.getId());
      if(!is_owner){
        q.setInteger("status", PhotoBean.STATUS_NORMAL);
View Full Code Here

      hql.append(" AND r.photo.album.type=:album_type");
      hql.append(" AND (r.ownerOnly = 0 OR r.user.id=:userid)");
    }
    hql.append(" ORDER BY r.id DESC");
    Session ssn = getSession();
    Query q = ssn.createQuery(hql.toString());
    q.setInteger("status", PhotoReplyBean.STATUS_NORMAL);
    q.setInteger("photo_status", PhotoBean.STATUS_NORMAL);
    q.setInteger("site", site.getId());
    if(!is_owner){
      q.setInteger("album_type", AlbumBean.TYPE_PUBLIC);
View Full Code Here

    }
    hql.append("?)");
    Session ssn = getSession();
    try{
      beginTransaction();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, ownerId);
      int i=0;
      for(;i<bookmarkIds.length;i++){
        String s_id = (String)bookmarkIds[i];
        int id = -1;
View Full Code Here

  public void testReadHibernate() throws Exception {

    Session session = HibernateHelper.currentSession();
    session.beginTransaction();
    List result = session.createQuery("from Test").list();
    for (int i = 0; i < result.size(); i++) {
      Test tst = (Test) result.get(i);
      System.out.println(tst.getFirstname() + " " + tst.getName());
    }
    session.getTransaction().commit();
View Full Code Here

  public void testUpdateHibernate() throws Exception {

    Session session = HibernateHelper.currentSession();
    session.beginTransaction();
    List result = session.createQuery("from Test").list();
    for (int i = 0; i < result.size(); i++) {
      Test tst = (Test) result.get(i);
      tst.setZip(new Integer((int) System.currentTimeMillis()));
    }
    session.getTransaction().commit();
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()) {
View Full Code Here

    // --- list
    try {
      tx = session.beginTransaction();
      // Query q = session.createQuery("select ch.id from Channel as ch");
      // List result = q.list();
      List result = session.createQuery("from Channel").list();
      // List chs = session.find("from Channel as ch where cat.title = ?",
      //                         "Another category title", Hibernate.STRING);
      tx.commit();
      Iterator it = result.iterator();
      while (it.hasNext()) {
View Full Code Here

      Channel aChannel = null;
      try {
        builder.beginTransaction();
        Session sess = builder.getSession();
        List channels =
          sess.createQuery("from Channel as chan where chan.locationString = :loc")
              .setParameter("loc", xmlURL, Hibernate.STRING).list();
        log.info("***locateChannel for " + xmlURL + " produced these: " + channels);
        if (channels.size() >= 1) { // for now just take the last one
          aChannel = (Channel) channels.get(channels.size() - 1);
        }
View Full Code Here

  int delete(String query, Object value, Type type) {
    int deleted = 0;
    try {
      // old: deleted = getSession().delete(query, value, type);
      Session si = getSession();
      Query qu = si.createQuery(query);
      qu.setParameter(0, value, type);
      List foundToDel = qu.list();
      int deletionCount = foundToDel.size();
      for (int i = 0; i < deletionCount; i++ ) {
        si.delete( foundToDel.get(i) );
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.