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 8510599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:44:59+00:00 2026-06-11T03:44:59+00:00

Getting Exception while running query using Criteria API org.hibernate.QueryException: could not resolve property: com

  • 0

Getting Exception while running query using Criteria API

 org.hibernate.QueryException: could not resolve property: com of: com.data.Collage        at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)
    at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:38)
    at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1362)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.getPathEntityName(CriteriaQueryTranslator.java:204)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.createCriteriaEntityNameMap(CriteriaQueryTranslator.java:191)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.<init>(CriteriaQueryTranslator.java:81)
    at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:58)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1550)
    at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)

Having class definitions as follow

class Collage {
int id;
String collageName;
List lstStudent;
}

class Student{
String studentName;
int id;
}

Have done mapping for above classes.

Now I am trying to fetch collage name and student name in single query where I have collageID and StudentID with me. Used Criteria API for this.

Criteria cr = session.createCriteria("com.data.Collage","collageAlias");
cr.createAlias("com.data.Student","studentAlias");
cr.add(Restrictions.eq("collageAlias.id", "402882c2369bc53901369bc95d5f0137"));
cr.add(Restrictions.eq("studentAlias.id","ff80808134cbe5a10134d14ff20300a9"));

ProjectionList properties = Projections.projectionList();
properties.add(Projections.property("collageAlias.collageName"));
properties.add(Projections.property("studentAlias.studentName"));

cr.setProjection(properties);
List collage_student = cr.list();

I have try with Collage.class, removed alias name for collage as t’s default class for criteria API, But it didn’t work.

Any suggestion?

  • 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-11T03:45:00+00:00Added an answer on June 11, 2026 at 3:45 am

    When you do

    cr.createAlias("com.data.Student","studentAlias");
    

    Hibernate automatically thinks that Student is a field of the Collage class, as the criteria is built on that class. By creating an alias you automatically make a join on that particular entity.

    Since your Collage class does not have a property named “com.data.Student” it causes your error.

    You should consider refactoring your code a little bit. If you want the Collage to handle a list of Student entities, change List lstStudent to List<Student> lstStudent. Now, you can map the classes so that you tell Hibernate the relation between the 2 entities:

    @Entity
    class Collage {
        int id;
        String collageName;
        List<Student> lstStudent;
    }
    
    @Entity
    class Student{
        String studentName;
        Collage collage;
        int id;
    }
    

    In the Collage class for the List<Student> lstStudent getter you will have:

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "collage")
    public List<Student> getStudents() {
        return this.lstStudents;
    }
    

    , while in the Student class for the getter of Collage you will have:

    @ManyToOne(fetch = FetchType.LAZY)
    public Collage getCollage(){
        return this.collage;
    }
    

    This basically allows you to create a Criteria on the Collage class and have direct access with an alias to its list of Students:

    cr.createAlias("lstStudent", "studentsAlias");     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the following exception while adding data into database: org.hibernate.HibernateException: The database
While running some code I am getting a unhanded exception for file not found
I am getting this exception while running any JSP on my tomcat5.5 server.Do I
I am getting he following Exception while running my Quartz Schdular program. Below is
hi i am getting the following exception while running my application and my applicationContext.xml
I am Getting a run time Exception while using this code Runtime rt =
I am getting following exception while running BIRT from a Linux OS. Caused by:
Hi I am getting this exception while running the mobile form page in asp.net.
I am learning WCF and right now I am getting one exception while running
I'm getting this error while running tomcat 'java.lang.ClassNotFoundException: com.mysql.jdbc.Driver'. I'm using a combination of

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.