-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Nullpointer error in EBQL parse has me stumped
PostPosted: Tue Mar 21, 2006 2:36 am 
Beginner
Beginner

Joined: Wed Nov 30, 2005 10:25 pm
Posts: 25
Can't figure out why the error.

Using:
postgresql 8.1
hibernate-annotations-3.1beta8
hibernate-entitymanager-3.1beta6
jboss seam 1.0 beta2

I'm using an entity manager. I am trying to query my user object:
Code:
@AccessType("field")
@Entity
@Table(name="site_user")
@Name("user")
@Scope(ScopeType.SESSION)
@SequenceGenerator(name="seq", sequenceName="site_user_seq")
public class User
   implements java.io.Serializable
{
   private final static long serialVersionUID = 1l;

   // Fields
   @Id
   @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq")
   private Integer id;

   @Basic
   @NotNull
   @Length(max=25,min=4)
   private String username;
...


Here is my JSF method that is throwing the exception:
Code:
   @Create
   public User getCurrentUser()
   {
      Principal userPrincipal =
         ((HttpServletRequest)facesContext.getExternalContext().getRequest())
         .getUserPrincipal();
      
      if (userPrincipal == null) return null;

      if (currentUser == null)
      {
         currentUser = (User)entityManager.createQuery(
            "select u from User " +
            "where u.username = :username")
            .setParameter("username", userPrincipal.getName())
            .getSingleResult();
      }
      
      return currentUser;
   }


Tomcat/Seam spit so many errors out that I cannot get any generated SQL (I don't think it got that far though).

Here is the relevant part of the error:
Code:
Caused by: java.lang.NullPointerException
   at org.hibernate.hql.ast.tree.IdentNode.resolveAsNakedComponentPropertyRefLHS(IdentNode.java:195)
   at org.hibernate.hql.ast.tree.IdentNode.resolve(IdentNode.java:85)
   at org.hibernate.hql.ast.tree.DotNode.resolveFirstChild(DotNode.java:139)
   at org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:397)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4316)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1211)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4032)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3518)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1758)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
   at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
   at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
   at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
   at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:54)
   at org.bethanyefree.beans.UserBeanAction.getCurrentUser(UserBeanAction.java:65)
...


My user has a "getUsername()" as well as the field being mapped with the same name ("username"). I cannot see what is wrong with that EBQL. Would appreciate it if someone can see the problem.

Thanks,
Andrew


Top
 Profile  
 
 Post subject: SOLVED
PostPosted: Wed Mar 22, 2006 12:55 am 
Beginner
Beginner

Joined: Wed Nov 30, 2005 10:25 pm
Posts: 25
It was a bad typo, guess I was too tired. I forgot the alias of the class ("User u" instead of "User"). Too bad the exception was no help at all.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 25, 2006 9:08 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Open a JIRA issue anyway, this is not really clean on our side

http://opensource.atlassian.com/project ... board.jspa

on Hibernate3 project

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.