Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8402073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:57:26+00:00 2026-06-09T21:57:26+00:00

When I run this query in my spring project it just return an error.

  • 0

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.

All other classes are : User ,Role and User_Role spring security

    public List<User> getUsersByNameOrLogin(final String value){
    List<User> result = new ArrayList<User>(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;
}  

And the error is :

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]

and all the error message :

    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.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:57:27+00:00Added an answer on June 9, 2026 at 9:57 pm

    Why are you including the value variable if you want to use named parameters? Moreover property names are case-sensitive. Change to:

    final String jpql = "SELECT u FROM User u WHERE "
      "    u.lastName  like :lastname" +;
      " OR u.firstName like :firstname" +;
      " OR u.email     like :email";
    

    And yes, StringBuilder is unnecessary here. You can simplify it even further by using only one parameter:

    final String jpql = "SELECT u FROM User u WHERE "
      "    u.lastName  like :valueLike" +;
      " OR u.firstName like :valueLike" +;
      " OR u.email     like :valueLike";
    
    result =  entityManager.createQuery(jpql, User.class)
            .setParameter("valueLike", valueLike)
            .getResultList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting an error when I run this query because the data type
If I run this query in Toad: SELECT BANDID, BANDNAME FROM WOODSTOCK WHERE BANDNAME
If I try to run this query in SQL Server 2005: SELECT 1 WHERE
Hi I am trying to run this query in SQL but it is not
I have the following query, now the strange thing is if I run this
I have a custom SQL query that I run with this line: @avg_score =
My scenario is this: I have a base NHibernate query to run of the
Hey guys I am getting this exception when trying to run the query Column
My XML document looks like this When I run XPATH query //collected_objects , I
I'm currently trying to run a LINQ query over a MS SQL database. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.