我正在使用Hibernate和MySQL并面临有关查询sql的问题
休眠服务:
List<RenterDto> list = new ArrayList<RenterDto>(0);
try {
Query query = session.createSQLQuery(sqlString);
query.setParameter(0, name);
list = query.setResultTransformer(new AliasToBeanResultTransformer(RenterDto.class)).list();
} catch (HibernateException e) {
logger.error("error at RenterDaoImpl.searchByNamePersonalId: " + e.getMessage());
} finally {
session.close();
}
return list;
SQL:
SELECT
R.ID,
R.NAME,
R.PERSONAL_ID,
R.PHONENUMBER,
R.EMAIL
FROM
RENTER R
WHERE
LOWER(R.NAME)
LIKE
CONCAT('%', '?')
调试时记录消息:
RenterDaoImpl - error at RenterDaoImpl.searchByNamePersonalId: Position beyond number of declared ordinal parameters.
Remember that ordinal parameters are 1-based! Position: 1
我该如何解决这个问题,非常感谢!
答案 0 :(得分:0)
只需执行错误消息
$(document).on('submit', 'form', function(e) {
e.preventDefault();
var query = $(this).serialize()
console.log(query)
})