我的 Web 应用程序有问题:在管理 bean 中我有:
private boolean isUserInDB() {
List users = userFacade.findByLogin(registerLog);
if(users.isEmpty())
return false;
return true;
}
当这个方法开始时,我有这个异常(可能来自 userFacade):
javax.el.ELException: javax.ejb.EJBException:The bean encountered a non-application exception;
nested exception is: <openjpa-2.2.0-r422266:1244990 fatal general error> org.apache.openjpa.persistence.PersistenceException:
user lacks privilege or object not found: USER {SELECT t0.id_user, t0.login, t0.password FROM USER t0 WHERE (t0.login = ?)} [code=-5501, state=42501]
FailedObject: SELECT u FROM User u WHERE u.login = :login [java.lang.String]
viewId=/pages/register.xhtml
location=/home/jakub/Projekty/Collv2/build/web/pages/register.xhtml
phaseId=INVOKE_APPLICATION(5)
Caused by:
org.apache.openjpa.lib.jdbc.ReportingSQLException - user lacks privilege or object not found: USER {SELECT t0.id_user, t0.login, t0.password FROM USER t0 WHERE (t0.login = ?)} [code=-5501, state=42501]
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:247)
or
Caused by:
org.apache.openjpa.lib.jdbc.ReportingSQLException - type not found or user lacks
privilege: TEXT {stmnt 1932110061 CREATE TABLE COURSE (id_course SMALLINT NOT NULL,
code VARCHAR(255), description TEXT, name VARCHAR(255), realization INTEGER, version
SMALLINT, PRIMARY KEY (id_course)) ENGINE = innodb} [code=-5509, state=42509]
/pages/register.xhtml at line 26 and column 104 action="#{registerController.register}"
User.class 和 UserFacade 在 Netbeans 中自动生成(“来自数据库的实体类......”和“来自实体类的会话 Bean......”:
你能帮我理解什么是“用户缺乏特权”吗?
编辑:
问题在这里:
public List<User> findByLogin(String login){
Query q = em.createNamedQuery("User.findByLogin").setParameter("login", login);
List list = q.getResultList();
return list;
}
创建查询时抛出异常