同じパラメーターを複数回使用するより大きな SQL ステートメントで MyBatis インターフェースをセットアップしようとしています。私のコードは次のとおりです。
@Select({
"select cnfp_nr_years, cnfp_nr_credits, cnfp_credits_activities, cnfp_credits_studies, cnfp_credits_professional_evolution, cnfp_credits_programs_first_second, cnfp_credits_programs_third_fourth ",
"from ",
"(select cnfp_parameter_value as cnfp_nr_years ",
"from cnfp_parameters ",
"where cnfp_parameter_name='PARAM_NR_YEARS' ",
"and CNFP_PARAMETER_START_DATE <= #{cnfpProcessingDate,jdbcType=DATE} ",
"and (cnfp_parameter_end_date is null or cnfp_parameter_end_date >= #{cnfpProcessingDate,jdbcType=DATE})) as param1, ",
"(select cnfp_parameter_value as cnfp_nr_credits ",
"from cnfp_parameters ",
"where cnfp_parameter_name='PARAM_NR_CREDITS' ",
"and CNFP_PARAMETER_START_DATE <= #{cnfpProcessingDate,jdbcType=DATE} ",
"and (cnfp_parameter_end_date is null or cnfp_parameter_end_date >= #{cnfpProcessingDate,jdbcType=DATE})) as param2, ",
"(select coalesce(sum(cnfp_teacher_activity_cpt_equiv),0) as cnfp_credits_activities ",
"from cnfp_teacher_activities ",
"where cnfp_person_id = #{cnfpPersonId,jdbcType=BIGINT} ",
"and cnfp_teacher_activity_date_equiv <= #{cnfpProcessingDate,jdbcType=DATE}' ",
"and cnfp_teacher_activity_date_expiry >= #{cnfpProcessingDate,jdbcType=DATE}) as activities, ",
"(select coalesce(sum(cnfp_teacher_study_cpt_equiv), 0) as cnfp_credits_studies ",
"from cnfp_teacher_studies ",
"where cnfp_person_id = #{cnfpPersonId,jdbcType=BIGINT} ",
"and cnfp_institution_id is not null ",
"and cnfp_teacher_study_date_equiv <= #{cnfpProcessingDate,jdbcType=DATE} ",
"and cnfp_teacher_study_date_expiry >= #{cnfpProcessingDate,jdbcType=DATE}) as studies, ",
"(select coalesce(sum(cnfp_teacher_study_cpt_equiv), 0) as cnfp_credits_professional_evolution ",
"from cnfp_teacher_studies ",
"where cnfp_person_id = #{cnfpPersonId,jdbcType=BIGINT} ",
"and cnfp_professional_level_id is not null ",
"and cnfp_teacher_study_date_equiv <= #{cnfpProcessingDate,jdbcType=DATE} ",
"and cnfp_teacher_study_date_expiry >= #{cnfpProcessingDate,jdbcType=DATE}) as professional_evolution, ",
"(select coalesce(sum(case when cnfp_program_categories_code in (1,2) then cnfp_program_module_cpt_equiv else 0 end), 0) as cnfp_credits_programs_first_second, ",
"coalesce(sum(case when cnfp_program_categories_code in (3,4) then cnfp_program_module_cpt_equiv else 0 end), 0) as cnfp_credits_programs_third_fourth ",
"from cnfp_teacher_learning_activities ",
"left join cnfp_teacher_learning_activities_x_program_modules on cnfp_teacher_learning_activities.cnfp_teacher_learning_activity_id = cnfp_teacher_learning_activities_x_program_modules.cnfp_teacher_learning_activity_id ",
"left join cnfp_program_modules on cnfp_teacher_learning_activities_x_program_modules.cnfp_program_module_id = cnfp_program_modules.cnfp_program_module_id ",
"left join cnfp_programs on cnfp_program_modules.cnfp_program_id = cnfp_programs.cnfp_program_id ",
"left join cnfp_program_categories on cnfp_programs.cnfp_program_categories_id = cnfp_program_categories.cnfp_program_categories_id ",
"where cnfp_person_id = #{cnfpPersonId,jdbcType=BIGINT} ",
"and CNFP_TEACHER_LEARNING_ACTIVITY_STATUS = 1 ",
"and CNFP_TEACHER_LEARNING_ACTIVITY_GRAD_DATE <= #{cnfpProcessingDate,jdbcType=DATE} ",
"and CNFP_TEACHER_LEARNING_ACTIVITY_EXPIRY_DATE >= #{cnfpProcessingDate,jdbcType=DATE}) as learning_activities"
})
@Results({
@Result(column="cnfp_nr_years", property="cnfpParamVerifYears", jdbcType=JdbcType.BIGINT),
@Result(column="cnfp_nr_credits", property="cnfpParamCreditsAcc", jdbcType=JdbcType.BIGINT),
@Result(column="cnfp_credits_activities", property="cnfpCreditsActivities", jdbcType=JdbcType.BIGINT),
@Result(column="cnfp_credits_studies", property="cnfpCreditsStudies", jdbcType=JdbcType.BIGINT),
@Result(column="cnfp_credits_professional_evolution", property="cnfpCreditsProfessionalEvolution", jdbcType=JdbcType.BIGINT),
@Result(column="cnfp_credits_programs_first_second", property="cnfpCreditsProgramsFirstSecondCat", jdbcType=JdbcType.BIGINT),
@Result(column="cnfp_credits_programs_third_fourth", property="cnfpCreditsThirdFourthCat", jdbcType=JdbcType.BIGINT)
})
CptCalculator selectResults(@Param("cnfpPersonId")Long cnfpPersonId, @Param("cnfpProcessingDate")Date cnfpProcessingDate);
しかし、私は例外を取得し続けます:
java.sql.SQLException: Parameter index out of range (7 > number of parameters, which is 6).] with root cause
java.sql.SQLException: パラメータ インデックスが範囲外です (7 > パラメータの数、つまり 6)。
なぜだか途方にくれます。どんな助けでもいただければ幸いです