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, inode "
      + tableName + "_1_ where tree.parent = ? and tree.child = " + tableName + ".inode and " + tableName
      + "_1_.inode = " + tableName + ".inode and "+tableName+"_1_.type = '"+tableName+"' and " + condition;

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

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

      dh.setSQLQuery(sql);

      // dh.setQuery("from inode in class " + c.getName() + " where ? in
      // inode.parents.elements");
      dh.setParam(inode.getInode());

      return dh.load();
    } catch (Exception e) {
      Logger.error(InodeFactory.class, "getChildrenClass 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 tree.relation_type=? and " + condition;

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

      dh.setSQLQuery(sql);

      // dh.setQuery("from inode in class " + c.getName() + " where ? in
      // inode.parents.elements");
      dh.setParam(inode);
      dh.setParam(relationType);

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

      return dh.load();
    } catch (Exception e) {
      Logger.error(InodeFactory.class, "getChildrenClass 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);

      // dh.setQuery("from inode in class " + c.getName() + " where ? in
      // (select tree.parent from com.dotmarketing.beans.Tree tree
      // where inode.inode = tree.child and tree.relationType = ?)");
      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 tree.relation_type = ? ";

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

      dh.setSQLQuery(sql);

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

      dh.setParam(p.getInode());
      dh.setParam(relationType);

      return dh.load();
    } catch (Exception e) {
      Logger.error(InodeFactory.class, "getChildrenClass 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+"'";

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

      dh.setSQLQuery(sql);

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

      dh.setParam(p.getInode());

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

      return dh.list();
    } catch (Exception e) {
      Logger.error(InodeFactory.class, "getChildrenClass failed:" + e, e);
      throw new DotRuntimeException(e.toString());
    }

View Full Code Here

      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+"' order by " + orderBy;

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

      dh.setSQLQuery(sql);

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

      dh.setParam(p.getInode());

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

      return dh.list();
    } catch (Exception e) {
      Logger.error(InodeFactory.class, "getChildrenClass 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;

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

      dh.setSQLQuery(sql);

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

      dh.setParam(p.getInode());

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

      return dh.list();
    } catch (Exception e) {
      Logger.error(InodeFactory.class, "getChildrenClass 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+"' order by  " + order;

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

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

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

      dh.setSQLQuery(sql);

      dh.setParam(p.getInode());

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

      return dh.list();
    } catch (Exception e) {
      Logger.error(InodeFactory.class, "getChildrenClassByOrder 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+"' order by  rand()";

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

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

      dh.setFirstResult(offset);
      dh.setMaxResults(limit);

      dh.setSQLQuery(sql);

      dh.setParam(p.getInode());

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

      return dh.list();
    } catch (Exception e) {
      Logger.error(InodeFactory.class, "getChildrenClassByOrder failed:" + e, e);
      throw new DotRuntimeException(e.toString());
    }

View Full Code Here

    try {
      if( c.equals(Identifier.class)){
        throw new DotStateException("Identifiers are no longer Inodes!");
      }
      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;

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

      dh.setSQLQuery(sql);

      Logger.debug(InodeFactory.class, "inode:  " + p1 + "\n");
      Logger.debug(InodeFactory.class, "inode:  " + 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, "getChildrenClassByCondition 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.length + 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.length + 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 ");
        }
      }

      String query = sql.toString();
      query = query.substring(0, query.lastIndexOf("and"));

      // Validate condition
      condition = (UtilMethods.isSet(condition) ? " and " + condition : "");
      // Validate order
      orderBy = (UtilMethods.isSet(orderBy) ? " order by " + orderBy : "");

      // Create the final query
      query += condition + orderBy;

      // Set the query
      dh.setSQLQuery(query);

      for (int x = 0; x < inodes.length; x++) {
        dh.setParam(inodes[x]);
      }

      return dh.list();
    } catch (Exception e) {
      Logger.debug(InodeFactory.class, "getChildrenClassByConditionAndOrderBy 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.