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

  • SEARCH
  • Home
  • 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 3220766
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:47:56+00:00 2026-05-17T15:47:56+00:00

This is my code, which I can’t even compile: /** * Find a project

  • 0

This is my code, which I can’t even compile:

/**
 * Find a project that has NO employee assigned yet.
 */
public Project findEmptyProject() {
  // getting criteria builder
  CriteriaBuilder cb = this.em.getCriteriaBuilder();
  // gathering meta information about left-joined entity
  Metamodel m = this.em.getMetamodel();
  EntityType<Employee> Employee_ = m.entity(Employee.class);
  // creating query
  CriteriaQuery<Project> cq = cb.createQuery(Project.class);
  // setting query root for the query
  Root<Project> project = cq.from(Project.class);
  // left-joining with another employees
  Join<Employee, Project> projects = project.join(
    Employee_.project, 
    JoinType.LEFT
  );
  // instructing the query to select only projects
  // where we have NO employees
  cq.select(project).where(Employee_.id.isNull());
  // fetching real data from the database
  return this.em.createQuery(cq).getSingleResult();
}

My model classes are:

public class Employee {
  @Id private Integer id;
  @ManyToOne private Project project;
  private String name;
}

public class Project {
  @Id private Integer id;
  private String name;
}

Compiler says (and I would say the same being a compiler):

Finder.java: cannot find symbol: variable project
location: interface javax.persistence.metamodel.EntityType<com.XXX.Employee>

What am I doing wrong?

  • 1 1 Answer
  • 1 View
  • 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-05-17T15:47:57+00:00Added an answer on May 17, 2026 at 3:47 pm

    When you use Employee_.project syntax, Employee_ must be an autogenerated metamodel class, not an EntityType obtained via Metamodel.entity().

    Hibernate JPA 2 Metamodel Generator manual explains how to configure generation of these classes in Hibernate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code is giving me this error, which I don't understand. I can't even
In P.S. of this posting you can find a C# code snippet, which uses
I have this code which can display drop down in div tag of html.
How I can delete an object which I had added before with this code.
I have a td-element which can contain some HTML code, e.g. &lt; . This
I need to change a piece of code which includes this: string.indexOf(bc) How can
I have the following code which is working, I was wondering if this can
Is there any thread library which can parse through code and find blocks of
Recently I was introduced to this OCaml code which in Haskell can be written
how can i convert http to h$#t!t@@^#p i have seen this code which was

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.