當前位置: 首頁>>代碼示例>>Java>>正文


Java Where.isNull方法代碼示例

本文整理匯總了Java中com.j256.ormlite.stmt.Where.isNull方法的典型用法代碼示例。如果您正苦於以下問題:Java Where.isNull方法的具體用法?Java Where.isNull怎麽用?Java Where.isNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.j256.ormlite.stmt.Where的用法示例。


在下文中一共展示了Where.isNull方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: byColumns

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public static Assignment byColumns(Map<String, Object> constraints) {
  try {
    Where<Assignment, Integer> where = Assignment.dao.queryBuilder().where();
    Boolean first = true;
    for (Map.Entry<String, Object> constraint: constraints.entrySet()) {
      if (!first) {
        where = where.and();
      }
      if (constraint.getValue() == null) {
        where = where.isNull(constraint.getKey());
      } else {
      	where = where.eq(constraint.getKey(), constraint.getValue());
      }
      first = false;
    }
    return Assignment.dao.queryForFirst(where.prepare());
  } catch (SQLException e) {
    e.printStackTrace();
    return null;
  }
}
 
開發者ID:instructure,項目名稱:MinecraftLTI,代碼行數:22,代碼來源:Assignment.java

示例2: byColumns

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public static LTIConsumer byColumns(Map<String, Object> constraints) {
  try {
    Where<LTIConsumer, Integer> where = LTIConsumer.dao.queryBuilder().where();
    Boolean first = true;
    for (Map.Entry<String, Object> constraint: constraints.entrySet()) {
      if (!first) {
        where = where.and();
      }
      if (constraint.getValue() == null) {
          where = where.isNull(constraint.getKey());
        } else {
        	where = where.eq(constraint.getKey(), constraint.getValue());
        }
      first = false;
    }
    return LTIConsumer.dao.queryForFirst(where.prepare());
  } catch (SQLException e) {
    e.printStackTrace();
    return null;
  }
}
 
開發者ID:instructure,項目名稱:MinecraftLTI,代碼行數:22,代碼來源:LTIConsumer.java

示例3: byColumns

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public static User byColumns(Map<String, Object> constraints) {
  try {
    Where<User, Integer> where = User.dao.queryBuilder().where();
    Boolean first = true;
    for (Map.Entry<String, Object> constraint: constraints.entrySet()) {
      if (!first) {
        where = where.and();
      }
      if (constraint.getValue() == null) {
        where = where.isNull(constraint.getKey());
      } else {
        where = where.eq(constraint.getKey(), constraint.getValue());
      }
      first = false;
    }
    return User.dao.queryForFirst(where.prepare());
  } catch (SQLException e) {
    e.printStackTrace();
    return null;
  }
}
 
開發者ID:instructure,項目名稱:MinecraftLTI,代碼行數:22,代碼來源:User.java

示例4: fetch

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
/**
 * Parametrized fetch Gets all BusinessObjects matching the parameters
 *
 * @param params Map of column = value, used in Where clause
 * @param limit  the maximum number of returned results. Values below 0 means no limit
 *
 * @return a list of all BusinessObjects matching the values provided by params
 *
 * @throws SQLException
 */
@Override
public List<BusinessObjectType> fetch(Map<String, Object> params, int limit) throws SQLException
{
	this.beforeFetch();
	List<BusinessObjectType> bos = null;

	if (params.containsValue(null) || limit >= 0) {
		QueryBuilder<BusinessObjectType, Integer> queryBuilder = dao.queryBuilder();
		Where<BusinessObjectType, Integer> where = queryBuilder.where();

		Iterator<Map.Entry<String, Object>> entryIterator = params.entrySet().iterator();
		while (entryIterator.hasNext()) {
			Map.Entry<String, Object> entry = entryIterator.next();

			if (entry.getValue() != null) {
				where.eq(entry.getKey(), entry.getValue());
			} else {
				where.isNull(entry.getKey());
			}

			if (entryIterator.hasNext()) {
				where = where.and();
			}
		}

		queryBuilder.setWhere(where);

		if (limit >= 0) {
			queryBuilder.limit((long) limit);
		}

		bos = dao.query(queryBuilder.prepare());
	} else {
		bos = dao.queryForFieldValues(params);
	}

	for (BusinessObjectType bo : bos) {
		this.afterFetch(bo);
	}

	return bos;
}
 
開發者ID:IAP12-16B,項目名稱:jManagr,代碼行數:53,代碼來源:AbstractDAL.java


注:本文中的com.j256.ormlite.stmt.Where.isNull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。