Package com.dotmarketing.db

Examples of com.dotmarketing.db.HibernateUtil


    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    try {
      String tableName = ((Inode) c.newInstance()).getType();
      HibernateUtil dh = new HibernateUtil(c);

      String sql = "SELECT {" + tableName + ".*} from " + tableName + " " + tableName
      + ", tree tree, tree tree2, inode " + tableName
      + "_1_ where tree.parent = ? and tree2.parent = ?  and tree.child = " + tableName
      + ".inode  and tree2.child = " + tableName + ".inode  and " + tableName + "_1_.inode = "
      + tableName + ".inode and "+tableName+"_1_.type = '"+tableName+"' and " + condition + " order by " + orderBy;

      Logger.debug(InodeFactory.class, "hibernateUtilSQL:getChildrenClassByCondition\n " + sql + "\n");

      dh.setSQLQuery(sql);

      Logger.debug(InodeFactory.class, "inode 1:  " + p1 + "\n");

      Logger.debug(InodeFactory.class, "inode 2:  " + p2 + "\n");

      dh.setParam(p1);
      dh.setParam(p2);

      if (limit != 0) {
        dh.setFirstResult(offset);
        dh.setMaxResults(limit);
      }

      return dh.list();
    } catch (Exception e) {
      Logger.warn(InodeFactory.class, "getChildrenClass failed:" + e, e);

      // throw new DotRuntimeException(e.toString());
    }
View Full Code Here


    }

    try {

      String tableName = ((Inode) c.newInstance()).getType();
      HibernateUtil dh = new HibernateUtil(c);

      StringBuffer sql = new StringBuffer("SELECT {" + tableName + ".*} from " + tableName + " " + tableName);

      for (int x = 1; x < inodes.size() + 1; x++) {
        if (x == 1) {
          sql.append(", tree tree ");
        } else {
          sql.append(", tree tree" + x + " ");
        }
      }
      sql.append(", inode " + tableName + "_1_ ");

      sql.append(" where "+tableName+"_1_.type = '"+tableName+"' and ");

      sql.append(tableName + "_1_.inode =  " + tableName + ".inode and ");
      for (int x = 1; x < inodes.size() + 1; x++) {
        if (x == 1) {
          sql.append(" ( tree.parent = ? and ");
          sql.append(" tree.child = " + tableName + ".inode ) ");
        } else {
          sql.append(" and (tree" + x + ".parent = ?  and ");
          sql.append(" tree" + x + ".child = " + tableName + ".inode ) ");
        }
      }

      // only if we send condition
      if (UtilMethods.isSet(condition)) {
        sql.append(" and " + condition);
      }

      // only if we send orderby
      if (UtilMethods.isSet(orderBy)) {
        sql.append(" order by ");
        sql.append(orderBy);
      }

      dh.setSQLQuery(sql.toString());

      for (int x = 0; x < inodes.size(); x++) {
        Inode i = (Inode) inodes.get(x);
        dh.setParam(i.getInode());
      }
      if (limit != 0) {
        dh.setFirstResult(offset);
        dh.setMaxResults(limit);
      }

      return dh.list();
    } catch (Exception e) {
      Logger.debug(InodeFactory.class, "getChildrenClassByConditionAndOrderBy failed:" + e, e);

      // throw new DotRuntimeException(e.toString());
    }
View Full Code Here

    }

    try {

      String tableName = ((Inode) c.newInstance()).getType();
      HibernateUtil dh = new HibernateUtil(c);

      StringBuffer sql = new StringBuffer("SELECT {" + tableName + ".*} from " + tableName + " " + tableName);

      for (int x = 1; x < inodes.size() + 1; x++) {
        if (x == 1) {
          sql.append(", tree tree, ");
        } else {
          sql.append(", tree tree" + x + ", ");
        }
      }
      sql.append(" inode " + tableName + "_1_ ");
      sql.append(" where "+tableName+"_1_.type = '"+tableName+"' and ");

      sql.append(tableName + "_1_.inode =  " + tableName + ".inode and ");
      for (int x = 1; x < inodes.size() + 1; x++) {
        if (x == 1) {
          sql.append(" ( tree.parent = ? and ");
          sql.append(" tree.child = " + tableName + ".inode ) and ");
        } else {
          sql.append(" (tree" + x + ".parent = ?  and ");
          sql.append(" tree" + x + ".child = " + tableName + ".inode ) and ");
        }
      }

      sql.append(condition);
      dh.setSQLQuery(sql.toString());

      for (int x = 0; x < inodes.size(); x++) {
        Inode i = (Inode) inodes.get(x);
        dh.setParam(i.getInode());
      }
      if (limit != 0) {
        dh.setFirstResult(offset);
        dh.setMaxResults(limit);
      }

      return dh.list();
    } catch (Exception e) {
      Logger.debug(InodeFactory.class, "getChildrenClassByConditionAndOrderBy failed:" + e, e);

      // throw new DotRuntimeException(e.toString());
    }
View Full Code Here

    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    try {
      String tableName = ((Inode) c.newInstance()).getType();
      HibernateUtil dh = new HibernateUtil(c);

      String sql = "SELECT {" + tableName + ".*} from " + tableName + " " + tableName + ", tree tree, inode "
      + tableName + "_1_ where tree.parent = ? and tree.child = " + tableName + ".inode and " + tableName
      + "_1_.inode = " + tableName + ".inode and "+tableName+"_1_.type = '"+tableName+"' and " + condition + " order by " + orderby;

      if(!UtilMethods.isSet(orderby))
        sql +=  tableName + ".inode desc";

      //sql += (sql.toLowerCase().indexOf("limit") == -1 ? ", " + tableName + ".inode desc" : "");

      Logger.debug(InodeFactory.class, "hibernateUtilSQL:getChildrenClassByConditionAndOrderBy\n " + sql + "\n");

      dh.setSQLQuery(sql);

      Logger.debug(InodeFactory.class, "inode:  " + p + "\n");

      dh.setParam(p);

      if (limit != 0) {
        dh.setFirstResult(offset);
        dh.setMaxResults(limit);
      }

      return dh.list();
    } catch (Exception e) {
      Logger.warn(InodeFactory.class, "getChildrenClassByConditionAndOrderBy failed:" + e, e);

      // throw new DotRuntimeException(e.toString());
    }
View Full Code Here

    }
   
   
    Inode inode = null;
    try {
      inode = (Inode) new HibernateUtil(c).load(x);
    } catch (Exception e) {
      //return (Inode) new HibernateUtil(c).load(x);
    }
    return inode;
  }
View Full Code Here

  public static java.util.List getInodesOfClass(Class c, int limit, int offset) {
    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    try {
      HibernateUtil dh = new HibernateUtil(c);
      String type = ((Inode) c.newInstance()).getType();
      dh.setQuery("from inode in class " + c.getName()+" where inode.type='"+type+"'");

      if (limit != 0) {
        dh.setFirstResult(offset);
        dh.setMaxResults(limit);
      }

      return dh.list();
    } catch (Exception e) {
      Logger.warn(InodeFactory.class, "getObjectsOfClass failed:" + e, e);
      // throw new DotRuntimeException(e.toString());
    }
View Full Code Here

  public static java.util.List getInodesOfClassByCondition(Class c, String condition, int limit, int offset) {
    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    try {
      HibernateUtil dh = new HibernateUtil(c);
      String type = ((Inode) c.newInstance()).getType();
      dh.setQuery("from inode in class " + c.getName() + " where inode.type='"+type+"' and " + condition);

      if (limit != 0) {
        dh.setFirstResult(offset);
        dh.setMaxResults(limit);
      }

      return dh.list();
    } catch (Exception e) {
      Logger.warn(InodeFactory.class, "getInodesOfClassByCondition(Class c, String condition) failed:" + e, e);

      // throw new DotRuntimeException(e.toString());
    }
View Full Code Here

  public static Object getInodeOfClassByCondition(Class c, String condition) {
    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    try {
      HibernateUtil dh = new HibernateUtil(c);
      String type = ((Inode) c.newInstance()).getType();
      dh.setQuery("from inode in class " + c.getName() + " where inode.type='"+type+"' and " + condition);
      Logger.debug(InodeFactory.class, "getInodeOfClassByCondition query: " + dh.getQuery());
      return dh.load();
    } catch (Exception e) {
      Logger.warn(InodeFactory.class, "getInodeOfClassByCondition(Class c, String condition) failed:" + e, e);

      // throw new DotRuntimeException(e.toString());
    }
View Full Code Here

      int limit, int offset) {
    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    try {
      HibernateUtil dh = new HibernateUtil(c);
      String type = ((Inode) c.newInstance()).getType();
      dh.setQuery("from inode in class " + c.getName() + " where inode.type='"+type+"' and " + condition + " order by " + orderby);
      if (limit != 0) {
        dh.setFirstResult(offset);
        dh.setMaxResults(limit);
      }

      return dh.list();
    } catch (Exception e) {
      Logger.warn(InodeFactory.class,
          "getInodesOfClassByCondition(Class c, String condition, String orderby) failed:" + e, e);
      // throw new DotRuntimeException(e.toString());
    }
View Full Code Here

  public static java.util.List getInodesOfClass(Class c, int maxRows) {
    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    try {
      HibernateUtil dh = new HibernateUtil(c);
      String type = ((Inode) c.newInstance()).getType();
      dh.setMaxResults(maxRows);
      dh.setQuery("from inode in class " + c.getName()+" where inode.type='"+type+"' ");

      return dh.list();
    } catch (Exception e) {
      Logger.warn(InodeFactory.class, "getObjectsOfClass failed:" + e, e);

      // throw new DotRuntimeException(e.toString());
    }
View Full Code Here

TOP

Related Classes of com.dotmarketing.db.HibernateUtil

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.