title: why my query or jpa query is not working in spring
body: <p>When I run this query in my spring project it just return an error.
  I tried with different methods without any result, would be very greatful if anybody can help me.
   I have 3 tables: User, Role and User_Role and my Address is embedded. Use join table too.</p>
  
  <p>All other classes are : <a href="https://stackoverflow.com/questions/12019290/user-role-and-user-role-spring-security">User ,Role and User_Role spring security</a>     </p>
  
  <pre><code>    public List&lt;User&gt; getUsersByNameOrLogin(final String value){
      List&lt;User&gt; result = new ArrayList&lt;User&gt;(0);
  
      if(value ==null){
          return result;
      }
  
      final StringBuilder jpql = new StringBuilder("SELECT u FROM User u WHERE ");
      jpql.append(" u.lastname like  "+value);
     jpql.append(" OR u.firstname like  "+value);
      jpql.append(" OR u.email like  "+value);
  
      final String valueLike = "%"+value+"%";
  
      result =  entityManager.createQuery(jpql.toString(), User.class)
              .setParameter("lastname", valueLike)
             .setParameter("firstname", valueLike)
             .setParameter("email", valueLike)
              .getResultList();
  
      return result;
  }  
  </code></pre>
  
  <p>And the error is :  </p>
  
  <p>could not resolve property: lastname of: User [SELECT u FROM User u WHERE  u.lastname like  pappo OR u.firstname like  pappo OR u.email like  pappo]</p>
  
  <p>and all the error message : </p>
  
  <pre><code>    Exception in thread "main" java.lang.IllegalArgumentException: org.hibernate.QueryException:      could not resolve property: lastname of: User [SELECT u FROM se.guard.User u WHERE  u.lastname like  pappo OR u.firstname like  pappo OR u.email like  pappo]
  at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1222)
  at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1168)
  at             org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:292)
  at se.datalayer.service.UserService.getUsersByNameOrLogin(UserService.java:189)
  at se.datalayer.main.Main.getUserByParam(Main.java:131)
  at se.datalayer.main.Main.main(Main.java:31)
       Caused by: org.hibernate.QueryException: could not resolve property: lastname of:      User [SELECT u FROM se.guard.User u WHERE  u.lastname like  pappo OR u.firstname like      pappo OR u.email like  pappo]
  at       org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:81)
  at        org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:75)
          at    org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1451)
  at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:312)
  at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:487)
  at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:611)
  at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:263)
  at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:210)
  at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:117)
  at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:113)
  at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:868)
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1323)
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4387)
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4004)
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1909)
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1859)
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1859)
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:824)
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:610)
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:294)
  at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:237)
  at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
  at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
  at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
  at org.hibernate.engine.query.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:101)
  at org.hibernate.engine.query.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:80)
  at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:98)
  at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
  at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
  at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1760)
  at    org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:277)
  ... 3 more
  </code></pre>