执行select时出现此问题:
我的StackTrace是:
显示java.lang.NullPointerException org.hibernate.hql.internal.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:394) org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3769) org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3555) org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3433) org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:708) org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:564) org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301) org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249) org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:250) org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185) org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) org.hibernate.engine.query.spi.HQLQueryPlan。(HQLQueryPlan.java:104) org.hibernate.engine.query.spi.HQLQueryPlan。(HQLQueryPlan.java:79) org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168) org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:222) org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:200) org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1703) org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:291) com.agostino.CrudJpa.selezione(CrudJpa.java:27) com.agostino.Gioia.doGet(Gioia.java:43) javax.servlet.http.HttpServlet.service(HttpServlet.java:620) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
我的课程是:
@Entity
public class Persona {
@Id
private int id;
private String nome;
private String cognome;
private String numero;
private String dataora;
get and set...
和
@Entity
public class LinkTable implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String clientid;
@Id
private int id;
private String cid;
private String dataora;
get and set...
我的查询是
String query="SELECT t FROM Persona t JOIN t.id s";
当我使用
时query="SELECT t FROM Persona t";
一切都好!
我使用文件persistence.xml