我当前的代码:
TypedQuery<Account> tp = em.createQuery("SELECT a FROM Account a INNER JOIN User u ON u.account_id = a.id WHERE a.email = :email AND a.pwd = :pwd AND a.role = 'admin'", Account.class);
tp.setParameter("email", this.username);
tp.setParameter("pwd", this.password);
Account result = tp.getSingleResult();
但我会得到一个 java.lang.IllegalArgumentException。
我需要的是在用户表中显示一列。
类似String name = Account.getName();
但 Account 实体没有 getName() 只有 User 实体有。
*更新
这是错误
java.lang.IllegalArgumentException:在 EntityManager 中创建查询时发生异常:异常描述:解析查询的语法错误 [SELECT a FROM Account a INNER JOIN User u ON u.account_id = a.id WHERE a.email = :email AND a.pwd = :pwd AND a.role = 'admin']。内部异常:org.eclipse.persistence.internal.libraries.antlr.runtime.EarlyExitException