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


Java Where.and方法代碼示例

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


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

示例1: getActualDialogOccupantsByIds

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<DialogOccupant> getActualDialogOccupantsByIds(String dialogId, List<Integer> userIdsList) {
    List<DialogOccupant> dialogOccupantsList = Collections.emptyList();

    try {
        QueryBuilder<DialogOccupant, Long> queryBuilder = dao.queryBuilder();
        Where<DialogOccupant, Long> where = queryBuilder.where();
        where.and(
                where.in(QMUserColumns.ID, userIdsList),
                where.eq(DialogOccupant.Column.STATUS, DialogOccupant.Status.ACTUAL),
                where.eq(Dialog.Column.ID, dialogId)
        );
        PreparedQuery<DialogOccupant> preparedQuery = queryBuilder.prepare();
        dialogOccupantsList = dao.query(preparedQuery);
    } catch (SQLException e) {
        ErrorUtils.logError(e);
    }

    return dialogOccupantsList;
}
 
開發者ID:QuickBlox,項目名稱:q-municate-android,代碼行數:20,代碼來源:DialogOccupantDataManager.java

示例2: getActualDialogOccupantsByDialog

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<DialogOccupant> getActualDialogOccupantsByDialog(String dialogId) {
    List<DialogOccupant> dialogOccupantsList = Collections.emptyList();

    try {
        QueryBuilder<DialogOccupant, Long> queryBuilder = dao.queryBuilder();
        Where<DialogOccupant, Long> where = queryBuilder.where();
        where.and(
                where.eq(DialogOccupant.Column.STATUS, DialogOccupant.Status.ACTUAL),
                where.eq(Dialog.Column.ID, dialogId)
        );
        PreparedQuery<DialogOccupant> preparedQuery = queryBuilder.prepare();
        dialogOccupantsList = dao.query(preparedQuery);
    } catch (SQLException e) {
        ErrorUtils.logError(e);
    }

    return dialogOccupantsList;
}
 
開發者ID:QuickBlox,項目名稱:q-municate-android,代碼行數:19,代碼來源:DialogOccupantDataManager.java

示例3: getDialogNotificationByDialogId

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public DialogNotification getDialogNotificationByDialogId(boolean firstMessage, List<Long> dialogOccupantsList) {
    DialogNotification dialogNotification = null;

    try {
        QueryBuilder<DialogNotification, Long> queryBuilder = dao.queryBuilder();
        Where<DialogNotification, Long> where = queryBuilder.where();
        where.and(
                where.in(DialogOccupant.Column.ID, dialogOccupantsList),
                where.eq(DialogNotification.Column.STATE, State.READ)
        );
        queryBuilder.orderBy(DialogNotification.Column.CREATED_DATE, firstMessage);
        PreparedQuery<DialogNotification> preparedQuery = queryBuilder.prepare();
        dialogNotification = dao.queryForFirst(preparedQuery);
    } catch (SQLException e) {
        ErrorUtils.logError(e);
    }

    return dialogNotification;
}
 
開發者ID:QuickBlox,項目名稱:q-municate-android,代碼行數:20,代碼來源:DialogNotificationDataManager.java

示例4: getMessageByDialogId

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public Message getMessageByDialogId(boolean firstMessage, List<Long> dialogOccupantsList) {
    Message message = null;

    try {
        QueryBuilder<Message, Long> queryBuilder = dao.queryBuilder();
        Where<Message, Long> where = queryBuilder.where();
        where.and(
                where.in(DialogOccupant.Column.ID, dialogOccupantsList),
                where.eq(Message.Column.STATE, State.READ)
        );
        queryBuilder.orderBy(Message.Column.CREATED_DATE, firstMessage);
        PreparedQuery<Message> preparedQuery = queryBuilder.prepare();
        message = dao.queryForFirst(preparedQuery);
    } catch (SQLException e) {
        ErrorUtils.logError(e);
    }

    return message;
}
 
開發者ID:QuickBlox,項目名稱:q-municate-android,代碼行數:20,代碼來源:MessageDataManager.java

示例5: deleteTempMessages

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public void deleteTempMessages(List<Long> dialogOccupantsIdsList) {
    try {
        DeleteBuilder<Message, Long> deleteBuilder = dao.deleteBuilder();

        Where<Message, Long> where = deleteBuilder.where();
        where.and(
                where.in(DialogOccupant.Column.ID, dialogOccupantsIdsList),
                where.or(
                        where.eq(Message.Column.STATE, State.TEMP_LOCAL),
                        where.eq(Message.Column.STATE, State.TEMP_LOCAL_UNREAD)
                )
        );

        if (deleteBuilder.delete() > 0) {
            //TODO VT need to think how to send IDs to observers
            notifyObserversDeletedById(dialogOccupantsIdsList);
        }
    } catch (SQLException e) {
        ErrorUtils.logError(e);
    }

}
 
開發者ID:QuickBlox,項目名稱:q-municate-android,代碼行數:23,代碼來源:MessageDataManager.java

示例6: buildWhere

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
/**
 * help to build a where to query in database;;
 * @return
 */
private PreparedQuery buildWhere(String wantDay,int schoolWeek,String schoolWeekDsz) throws SQLException {
    QueryBuilder<ClassModel,Integer> queryBuilder = classDao.queryBuilder();
    queryBuilder.clear();
    Where<ClassModel,Integer> where = queryBuilder.where();
    where.and(
            where.like("day",wantDay),
            where.le("strWeek", schoolWeek),
            where.ge("endWeek", schoolWeek),
            where.or(
                    where.isNull("dsz"),
                    where.like("dsz",""),
                    where.like("dsz",schoolWeekDsz)
            )
    );
    return queryBuilder.prepare();
}
 
開發者ID:iSCAU,項目名稱:iSCAU-Android,代碼行數:21,代碼來源:ClassHelper.java

示例7: 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

示例8: 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

示例9: 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

示例10: findByFrom

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<PickupInfo> findByFrom(LocalDate d, boolean includeTaken) {

        try {

            Where<PickupInfo, Long> where = dao.queryBuilder().where();
            where.eq(PickupInfo.COLUMN_FROM, d);
            if (!includeTaken) {
                where.and();
                where.eq(PickupInfo.COLUMN_TAKEN, false);
            }
            return where.query();

        } catch (SQLException e) {
            throw new RuntimeException("Error finding model", e);
        }

        //return findBy(PickupInfo.COLUMN_FROM, d);
    }
 
開發者ID:citiususc,項目名稱:calendula,代碼行數:19,代碼來源:PickupInfoDao.java

示例11: exists

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public PickupInfo exists(PickupInfo pickupInfo) {
    try {
        QueryBuilder<PickupInfo, Long> qb = dao.queryBuilder();
        Where w = qb.where();
        w.and(
                w.eq(PickupInfo.COLUMN_MEDICINE, pickupInfo.getMedicine()),
                w.eq(PickupInfo.COLUMN_FROM, pickupInfo.getFrom()),
                w.eq(PickupInfo.COLUMN_TO, pickupInfo.getTo())
        );
        qb.setWhere(w);
        return qb.queryForFirst();

    } catch (SQLException e) {
        throw new RuntimeException("Error finding scanned schedule", e);
    }
}
 
開發者ID:citiususc,項目名稱:calendula,代碼行數:17,代碼來源:PickupInfoDao.java

示例12: testUseOfAndMany

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testUseOfAndMany() throws Exception {
	Dao<Foo, Integer> dao = createDao(Foo.class, true);
	assertEquals(0, dao.countOf());
	Foo foo1 = new Foo();
	foo1.val = 1231231;
	assertEquals(1, dao.create(foo1));
	Foo foo2 = new Foo();
	foo2.val = foo1.val + 1;
	assertEquals(1, dao.create(foo2));

	Where<Foo, Integer> where = dao.queryBuilder().where();
	where.and(where.eq(Foo.VAL_COLUMN_NAME, foo1.val), where.eq(Foo.ID_COLUMN_NAME, foo1.id));

	List<Foo> results = where.query();
	assertEquals(1, results.size());
	assertEquals(foo1.id, results.get(0).id);

	// this should match none
	where.reset();
	where.and(where.eq(Foo.ID_COLUMN_NAME, foo1.id), where.eq(Foo.ID_COLUMN_NAME, foo2.id),
			where.eq(Foo.VAL_COLUMN_NAME, foo1.val), where.eq(Foo.VAL_COLUMN_NAME, foo2.val));
	results = where.query();
	assertEquals(0, results.size());
}
 
開發者ID:j256,項目名稱:ormlite-core,代碼行數:27,代碼來源:BaseDaoImplTest.java

示例13: getScheduledServicesByInterval

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
/**
 * Return a list of reservation wbetween specified
 *
 * @param beginDate
 * @param endDate
 * @param orderAscending
 * @return
 * @throws IOException
 */
public List<MerchantService> getScheduledServicesByInterval(Date beginDate, Date endDate, boolean orderAscending) throws IOException {

    if (beginDate.getTime() >= endDate.getTime()) {
        throw new IllegalArgumentException("Begin date must be lesser than " +
                "end date: b/" + beginDate + " e/" + endDate);
    }

    try {

        QueryBuilder<MerchantService, String> queryBuilder = dao.queryBuilder();
        queryBuilder.orderBy(MerchantService.EXECUTION_DATE_FIELD_NAME, orderAscending);
        Where<MerchantService, String> where = queryBuilder.where();

        where.and(
                where.eq(MerchantService.IS_SCHEDULED_FIELD_NAME, true),
                where.between(MerchantService.EXECUTION_DATE_FIELD_NAME, beginDate, endDate)
                /*,
                where.or(

                        where.eq(MerchantService.EXECUTION_DATE_FIELD_NAME, beginDate),
                        where.eq(MerchantService.EXECUTION_DATE_FIELD_NAME, endDate)
                )*/
        );

        List<MerchantService> results = queryBuilder.query();

        refresh(results);

        return results;
    } catch (Exception e) {
        throw new IOException(e);
    }
}
 
開發者ID:remipassmoilesel,項目名稱:simple-hostel-management,代碼行數:43,代碼來源:MerchantServiceService.java

示例14: getByCustomerId

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<MerchantService> getByCustomerId(Long customerId, Boolean paid, boolean orderAscending) throws IOException {

        try {

            QueryBuilder<MerchantService, String> queryBuilder = dao.queryBuilder();
            queryBuilder.orderBy(MerchantService.PURCHASE_DATE_FIELD_NAME, orderAscending);
            Where<MerchantService, String> where = queryBuilder.where();

            // search for paid or non-paid only
            if (paid != null) {
                where.and(
                        where.eq(MerchantService.CUSTOMER_FIELD_NAME, customerId),
                        where.eq(MerchantService.PAID_FIELD_NAME, paid)
                );
            }

            // search by customer id
            else {
                where.eq(MerchantService.CUSTOMER_FIELD_NAME, customerId);
            }

            List<MerchantService> results = queryBuilder.query();
            refresh(results);

            return results;
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
 
開發者ID:remipassmoilesel,項目名稱:simple-hostel-management,代碼行數:30,代碼來源:MerchantServiceService.java

示例15: getByInterval

import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<Reservation> getByInterval(Date beginDate, Date endDate, boolean orderAscending, Long accommodationId) throws IOException {

        try {
            QueryBuilder<Reservation, String> queryBuilder = dao.queryBuilder();
            queryBuilder.orderBy(Reservation.DATEBEGIN_FIELD_NAME, orderAscending);
            Where<Reservation, String> where = queryBuilder.where();

            if (accommodationId != -1) {
                where.and(
                        where.eq(Reservation.ACCOMMODATION_FIELD_NAME, accommodationId),
                        where.between(Reservation.DATEBEGIN_FIELD_NAME, beginDate, endDate)
                                .or().between(Reservation.DATEEND_FIELD_NAME, beginDate, endDate)
                );
            } else {
                where.between(Reservation.DATEBEGIN_FIELD_NAME, beginDate, endDate)
                        .or().between(Reservation.DATEEND_FIELD_NAME, beginDate, endDate);
            }

            List<Reservation> results = queryBuilder.query();

            for (Reservation r : results) {
                refresh(r);
            }

            return results;
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
 
開發者ID:remipassmoilesel,項目名稱:simple-hostel-management,代碼行數:30,代碼來源:ReservationService.java


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