Closed smilesman closed 11 years ago
经过实际验证,未重现此问题。 具体验证代码参考:XxBjDao @Query("select count(*) from XxBj t where t.bh = :bh") Long findXsCount(@Param("bh") String bh);
public class XxBjDaoTest extends SpringTransactionalTestCase {
@Autowired
private XxBjDao xxBjDao;
@Test
public void findXsCount() {
XxBj xxBj = TestObjectUtils.buildMockObject(XxBj.class);
xxBjDao.save(xxBj);
Long count = xxBjDao.findXsCount(xxBj.getBh());
Assert.assertTrue(count >= 1);
}
}
执行结果:
21:38:43.426 DEBUG jdbc.sqlonly[232] - sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
@Query("select count(*) from Holidays h where h.year=:year and h.month=:month and h.day >= 1 and h.day<=:day") public int getCountHoliday(@Param("year")int year,@Param("month")int month,@Param("day")int day);
会抛出参数不匹配的错误 Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1