以下是查詢:Hibernate的SQL查詢錯誤
Query q = getSession().createQuery("FROM secroles
WHERE secroles.SR_ORG = :srOrg ,
secroles.SR_PROFILE= :srUser,
ISDELETED=:isDeleted");
錯誤:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: , near line 1, column 37 [FROM secroles WHERE SR_ORG = :srOrg , SR_PROFILE= :srUser , ISDELETED = :ISDELETED]
功能齊全:
public String getSecroleByOrgNID(Organization srOrg, Profile srUser){try {
System.out.println("bug is here0");
begin();
Query q = getSession().createQuery("FROM secroles WHERE secroles.SR_ORG = :srOrg , secroles.SR_PROFILE= :srUser , ISDELETED=:isDeleted");
q.setParameter("srOrg", srOrg);
q.setParameter("srOrg", srUser);
q.setBoolean("isDeleted", false);
Secroles sr = (Secroles) q.uniqueResult();
Roletable rt = sr.getSrRole();
commit();
return rt.getRoleName();
} catch(HibernateException e) {
rollback();
e.printStackTrace();
System.out.println("Could not assign role\n Message: "+e.getMessage());
}
return null;
}
}
不工作,得到了錯誤: org.hibernate.hql.ast.QuerySyntaxException:意外的標記:,近線1,列37 FROM secroles WHERE secroles.srOrg =:SR_ORGsrOrg,secroles.srUser =: SR_PROFILE,ISDELETED =:ISDELETED] – 2011-05-31 18:54:27
你確定它是一樣的錯誤嗎?你是否按照我的建議使用了財產名稱?因爲你的名字看起來像列名。我建議 - 將您的查詢分配給變量,並打印出來。然後用精確的錯誤信息發佈輸出。 – 2011-05-31 18:57:49
什麼是白紋?它應該是類名。 – 2011-05-31 18:58:55