Exemplo n.º 1
0
  public List<Lecture> findBySpeaker(Speaker speaker) {
    List<Lecture> lectures = new ArrayList<Lecture>();

    QueryBuilder<LectureSpeaker, Integer> lectureSpeakerQB = getLectureSpeakerDao().queryBuilder();
    lectureSpeakerQB.selectColumns(LectureSpeaker.LECTURE_ID_FIELD_NAME);
    try {
      lectureSpeakerQB.where().eq(LectureSpeaker.SPEAKER_ID_FIELD_NAME, speaker);
      QueryBuilder<Lecture, Integer> lectureQB = getDao().queryBuilder();
      lectureQB.where().in(Lecture.ID_FIELD_NAME, lectureSpeakerQB);
      PreparedQuery<Lecture> lecturePrepare = lectureQB.prepare();

      return getDao().query(lecturePrepare);
    } catch (SQLException e) {
      e.printStackTrace();
      return lectures;
    }
  }
Exemplo n.º 2
0
  private PreparedQuery<ProjectBean> makeProjectForUserQuery() {

    QueryBuilder<UserProjectMapping, Integer> userPostQb = userProjectMappingDao.queryBuilder();

    userPostQb.selectColumns(UserProjectMapping.PROJECT_ID_FIELD_NAME);
    SelectArg userSelectArg = new SelectArg();
    QueryBuilder<ProjectBean, Integer> projectQb = null;
    try {
      userPostQb.where().eq(UserProjectMapping.USER_ID_FIELD_NAME, userSelectArg);
      projectQb = projectDao.queryBuilder();
      projectQb.where().eq("isDisabled", false).and().in(ProjectBean.ID_FIELD_NAME, userPostQb);
      return projectQb.prepare();
    } catch (SQLException e) {
      logger.error(
          "Error creating prepared query for fetching user mapped projects : " + e.getMessage());
    }
    return null;
  }