早上好,我从今天早上开始在DAOImpl方法上遇到这个错误......它突然发生了......
这是我的方法:
public int postiOccupatiParcheggio(Park park) {
Query pianiQuery = getSession().createQuery("from Piano p where p.park = :park");
pianiQuery.setParameter("park", park);
List <Piano> piani = pianiQuery.list();
Query postiQuery = getSession().createQuery("from Posto p where p.piano in :piani");
postiQuery.setParameterList("piani", piani);
List<Posto> posti = postiQuery.list();
Query query = getSession().createQuery("SELECT count(*) from Occupazione o where o.posto in :posti "
+ "and o.occupied = true and o.dateTime = (select max(oo.dateTime) from "
+ "Occupazione oo where o.posto = oo.posto)");
query.setParameterList("posti", posti);
Long r = null;
int result = 0;
try {
r = (Long) query.uniqueResult();
result = r.intValue();
} catch(NoResultException nre) {
result = 0;
}
return result;
}
我收到此异常
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error
in your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near ')) and occupazion0_.isOccupied=1 and
occupazion0_.date_time=(select max(occupazi' at line 1
和hibernate日志告诉:
SQL Error: 1064, SQLState: 42000
我读到这是一个错误,如果你使用一些限制变量名称会发生,但事实并非如此,最重要的是,直到昨天一切都很顺利......
我正在使用MySql 5.7.9并使用此属性:
hibernate.dialect = org.hibernate.dialect.MySQLDialect