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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:17:28+00:00 2026-06-15T23:17:28+00:00

In my current project I’ve faced a problem of getting entities with hibernate criteria

  • 0

In my current project I’ve faced a problem of getting entities with hibernate criteria query. I have the following entities:

  • Professor, which contains a list of students
  • Student, which contains a list of assignments.
  • Assignment, which contains id of student to which it is assigned to.

Now, I want to get all assignments relative to the professor, i.e. all assignments Professor assigned to his students.

This query shows what I want to implement in criteria query.

select * from Assigment p, Student a, Professor c where p.studentid = a.id and a.proffid = c.id and c.id = 2411;

How can I implement this query using hibernate criteria API?

  • 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-15T23:17:29+00:00Added an answer on June 15, 2026 at 11:17 pm

    suppose your tables like that:

    @Entity
    public class Professor{
        K id;
        List<Student> students;
    }
    
    @Entity
    public class Student{
        K profid;
        List<Assignments> assignments;
    }
    
    @Entity
    public class Assignments{
        K studentid;
    }
    

    simple sample by using alias:

    Criteria criteria = currentSession.createCriteria(Professor.class, "professor");
        criteria.createAlias("professor.students", "student");
        criteria.createAlias("student.assigments", "assigment");
        criteria.add(Restrictions.eqProperty("professor.id", "student.profid"));
        criteria.add(Restrictions.eqProperty("assigment.studentid", "student.profid"));
        criteria.add(Restrictions.eq("id", 2411));
    return criteria.list();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On my current project, which is a delivery system, I have a list of
In my current project, we have to create a website (ASP.NET MVC) which is
My current project is getting awfully large. I have dozens of activities, adapters, fragments,
In my current project, some tables have a column named changed, which indicates if
Whilst developing a current project which contains a number of WinForms, I'm finding myself
For my current project I have to send a signature from PHP to Java
my current project is based on Entity Framwork code-first. I have three types: Task,
My current project for work involves developing a SharePoint 2007 WebPart which will be
My current project is in rails 2.3.5 which uses restful authentication. I am moving
This is my current project structure: pom.xml /src /main /resources hibernate.cfg.xml /META-INF persistence.xml I

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.