Package com.dotmarketing.db

Examples of com.dotmarketing.db.HibernateUtil


  public static java.util.List getInodesOfClass(Class c, String orderBy, 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+"' order by " + orderBy);

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

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

    return new java.util.ArrayList();
View Full Code Here


    if( c.equals(Identifier.class)){
      throw new DotStateException("Identifiers are no longer Inodes!");
    }
    Object obj ;
    try {
      obj = new HibernateUtil(c).load(x);
    } catch (DotHibernateException e) {
      Logger.error(InodeFactory.class, "getObject failed:" + e, e);
      throw new DotRuntimeException(e.toString());
    }
    return obj;
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.child = ? and tree.parent = " + tableName + ".inode and " + tableName
      + "_1_.inode = " + tableName + ".inode and "+tableName+"_1_.type = '"+tableName+"'";

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

      dh.setSQLQuery(sql);
      dh.setParam(i);

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

      List list = dh.list();

      if ((list != null) && (list.size() != 0)) {
        return list.get(0);
      }
    } catch (Exception e) {
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
      + " with (nolock), tree tree with (nolock), inode " + tableName + "_1_ with (nolock) where tree.child = ? and tree.parent = "
      + tableName + ".inode and " + tableName + "_1_.inode = " + tableName + ".inode and "+tableName+"_1_.type = '"+tableName+"'";

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

      dh.setSQLQuery(sql);

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

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

      return dh.list();
    } catch (Exception e) {
      Logger.warn(InodeFactory.class, "getParentsOfClass 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.child = ? and tree.parent = " + tableName + ".inode and " + tableName
      + "_1_.inode = " + tableName + ".inode and tree.relation_type = ? and "+tableName+"_1_.type = '"+tableName+"' ";

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

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

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

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

      dh.setSQLQuery(sql);
      dh.setParam(p.getInode());

      return dh.list();
    } catch (Exception e) {
      Logger.warn(InodeFactory.class, "getParentsOfClassByCondition 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.child = ? and tree.parent = " + tableName + ".inode and " + tableName
      + "_1_.inode = " + tableName + ".inode and "+tableName+"_1_.type = '"+tableName+"' and " + condition;

      if(UtilMethods.isSet(sortOrder))
      {
        sql = sql + " order by "+ sortOrder; 
      }

      //Logger
      Logger.debug(InodeFactory.class, "hibernateUtilSQL:getParentsOfClassByCondition\n " + sql);
      Logger.debug(InodeFactory.class, "inode:  " + p.getInode() + "\n");
      Logger.debug(InodeFactory.class, "condition:  " + condition + "\n");
      // END Logger     

      dh.setSQLQuery(sql);
      dh.setParam(p.getInode());

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

  }

  public static java.util.List getChildrenClassByCondition(Inode p1, Inode p2, Class c, String condition) {
    try {
      String tableName =  ((Inode) c.newInstance()).getType();
      HibernateUtil dh = new HibernateUtil(c);
     
      String sql = "SELECT {"  + tableName + ".*} from " + tableName + " " + tableName + ", multi_tree multi_tree, inode "+ tableName +"_1_ where multi_tree.parent1 = ? and multi_tree.parent2 = ? and multi_tree.child = " + tableName + ".inode and " + tableName + "_1_.inode = " + tableName + ".inode and " + condition;
            Logger.debug(MultiTreeFactory.class, "hibernateUtilSQL:getChildrenClassByCondition\n " + sql);
      dh.setSQLQuery(sql);
            Logger.debug(MultiTreeFactory.class, "inode p1:  " + p1.getInode() + "\n");
            Logger.debug(MultiTreeFactory.class, "inode p2:  " + p2.getInode() + "\n");
     
      dh.setParam(p1.getInode());
      dh.setParam(p2.getInode());

      return dh.list();
    }
    catch (Exception e) {
            Logger.error(MultiTreeFactory.class, "getChildrenClassByCondition failed:" + e, e);
      throw new DotRuntimeException(e.toString());
    }
View Full Code Here

     * @param inode inode of the object tagged
     * @return list of all the TagInode where the tags are associated to the object
     */
  public List getTagInodeByInode(String inode) {
        try {
            HibernateUtil dh = new HibernateUtil(TagInode.class);
            dh.setQuery("from tag_inode in class com.dotmarketing.tag.model.TagInode where inode = ?");
            dh.setParam(inode);

            List list = dh.list();
          return list;

        } catch (Exception e) {
            Logger.warn(Tag.class, "getTagInodeByInode failed:" + e, e);
        }
View Full Code Here

  }

  public static java.util.List getChildrenClassByCondition(String p1, String p2, Class c, String condition) {
    try {
      String tableName =  ((Inode) c.newInstance()).getType();
      HibernateUtil dh = new HibernateUtil(c);
     
      String sql = "SELECT {"  + tableName + ".*} from " + tableName + " " + tableName + ", multi_tree multi_tree, inode "+ tableName +"_1_ where multi_tree.parent1 = ? and multi_tree.parent2 = ? and multi_tree.child = " + tableName + ".inode and " + tableName + "_1_.inode = " + tableName + ".inode and " + condition;
            Logger.debug(MultiTreeFactory.class, "hibernateUtilSQL:getChildrenClassByCondition\n " + sql);
      dh.setSQLQuery(sql);
            Logger.debug(MultiTreeFactory.class, "inode p1:  " + p1 + "\n");
            Logger.debug(MultiTreeFactory.class, "inode p2:  " + p2 + "\n");
     
      dh.setParam(p1);
      dh.setParam(p2);

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