Package com.liferay.portal.kernel.dao.orm

Examples of com.liferay.portal.kernel.dao.orm.SQLQuery


    try {
      session = openSession();

      String sql = CustomSQLUtil.get(COUNT_BY_G1_G2_U1_U2);

      SQLQuery q = session.createSQLQuery(sql);

      q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId1);
      qPos.add(groupId2);
      qPos.add(userId1);
      qPos.add(userId2);

      Iterator<Long> itr = q.list().iterator();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
View Full Code Here


    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G1_G2_U1_U2);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("SN_WallEntry", WallEntryImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId1);
      qPos.add(groupId2);
View Full Code Here

        connectionManager.closeConnection(connection);
    }

    public void executeUpdate(DBConnection dbConnection, String sql, List params, Map<String, Object> options) throws DBException {
        Session session = (Session) dbConnection.getNativeConnection();
        SQLQuery query = null;

        try {
            query = session.createSQLQuery(sql);
            QueryPos qpos = QueryPos.getInstance(query);
            for (Object item: params) {
                qpos.add(item);
            }
            log.debug(sql + "\n" + params);
            query.executeUpdate();
        } catch (Exception e) {
            throw new DBException(e);
        } finally {
            closeConnection(dbConnection);
        }
View Full Code Here

    }

    public List executeQuery(DBConnection dbConnection, String sql, List params,  LinkedHashMap<String, Integer> types) throws DBException {
        List items = new ArrayList();
        Session session = (Session) dbConnection.getNativeConnection();
        SQLQuery query = null;

        try {
            query = session.createSQLQuery(sql);
            QueryPos qpos = QueryPos.getInstance(query);
            for (Object item: params) {
                qpos.add(item);
            }
            log.debug(sql + "\n" + params);
            items = query.list();
//            for (Object item : items) {
//                if (item != null) {
//                    if (item.getClass().isArray()) {
//                        for (Object value : (Object[]) item) {
//                            System.out.println("1111111111 :" + value + " ;;;; type : " + (value != null ? value.getClass() : null));
View Full Code Here

        try {
            session = openSession();
            String qString = "SELECT Transaction.id, Book.id, Book.title, max(Transaction.id) AS max_Transaction__id FROM Transaction  RIGHT JOIN Book  ON Book.id = Transaction.bookId  GROUP BY Book.title";
//            String qString = "SELECT Transaction.id, Book.id, Book.title FROM Transaction  RIGHT JOIN Book  ON Book.id = Transaction.bookId";
            SQLQuery query = session.createSQLQuery(qString, true);
            query.addScalar("Book.id", Type.LONG);
            query.addScalar("Transaction.id", Type.LONG);
            query.addScalar("Book.title", Type.STRING);
            query.addScalar("max_Transaction__id", Type.LONG);
            System.out.println(qString);
            result = (List<Long>) QueryUtil.list(query, getDialect(), -1, -1);
        } catch (Exception e) {
            throw new SystemException(e);
        } finally {
View Full Code Here

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_EVENTNAME_EVENTDESCRIPTON_LOCATIONNAME);

      SQLQuery q = session.createSQLQuery(sql);
      q.setCacheable(false);
      q.addEntity("Event_Event", EventImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);
      qPos.add(eventName);
      qPos.add(eventDescription);
      qPos.add(locationName);
View Full Code Here

    Session session = null;

    try {
      session = openSession();

      SQLQuery q = session.createSQLQuery(sql);

      if (getDB().isSupportsInlineDistinct()) {
        q.addEntity(_FILTER_ENTITY_ALIAS, EventImpl.class);
      }
      else {
        q.addEntity(_FILTER_ENTITY_TABLE, EventImpl.class);
      }

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
View Full Code Here

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
        Event.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
        groupId);

    SQLQuery q = session.createSQLQuery(sql);

    q.setFirstResult(0);
    q.setMaxResults(2);

    if (getDB().isSupportsInlineDistinct()) {
      q.addEntity(_FILTER_ENTITY_ALIAS, EventImpl.class);
    }
    else {
      q.addEntity(_FILTER_ENTITY_TABLE, EventImpl.class);
    }

    QueryPos qPos = QueryPos.getInstance(q);

    qPos.add(groupId);

    if (orderByComparator != null) {
      Object[] values = orderByComparator.getOrderByConditionValues(event);

      for (Object value : values) {
        qPos.add(value);
      }
    }

    List<Event> list = q.list();

    if (list.size() == 2) {
      return list.get(1);
    }
    else {
View Full Code Here

    Session session = null;

    try {
      session = openSession();

      SQLQuery q = session.createSQLQuery(sql);

      q.addScalar(COUNT_COLUMN_NAME,
        com.liferay.portal.kernel.dao.orm.Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);

      Long count = (Long)q.uniqueResult();

      return count.intValue();
    }
    catch (Exception e) {
      throw processException(e);
View Full Code Here

    Session session = null;

    try {
      session = openSession();

      SQLQuery q = session.createSQLQuery(sql);

      if (getDB().isSupportsInlineDistinct()) {
        q.addEntity(_FILTER_ENTITY_ALIAS, LocationImpl.class);
      }
      else {
        q.addEntity(_FILTER_ENTITY_TABLE, LocationImpl.class);
      }

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
View Full Code Here

TOP

Related Classes of com.liferay.portal.kernel.dao.orm.SQLQuery

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.