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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:12:09+00:00 2026-06-04T16:12:09+00:00

I have the following code: Session session = (Session) em.getDelegate(); Criteria c = session.createCriteria(Term.class);

  • 0

I have the following code:

Session session = (Session) em.getDelegate();
Criteria c = session.createCriteria(Term.class);
c.setProjection(
        Projections.projectionList()
                .add(Projections.property("id"))
                .add(Projections.property("qualifier"))
                .add(Projections.property("preferred"))
                .add(Projections.property("terminology.definition"))
);
c.list();

but Hibernate chokes on terminology.definition with an exception
org.hibernate.QueryException: could not resolve property: terminology.definition of: net.*.Term

despite the fact that there is a property in Term:

@OneToOne(mappedBy = "term")
public Terminology getTerminology() { return terminology; }

and Terminology has a @Basic property named definition. I can fix it with an stupid-looking alias:

session.createCriteria(Term.class).createAlias("terminology", "terminology")

but it is undesirable.

  • 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-04T16:12:12+00:00Added an answer on June 4, 2026 at 4:12 pm

    This is pretty standard due to the way selects are being done.
    Terminology is mostly like brought in through a join on the SQL side, but in terms of the query, you have to define an alias in order to be able to access a joined table.

    In fact, if you look at the JavaDocs for Criteria class, there’s even an example of it:

    You may navigate associations using createAlias() or createCriteria().

     List cats = session.createCriteria(Cat.class)
         .createCriteria("kittens")
             .add( Restrictions.like("name", "Iz%") )
         .list();
    
     List cats = session.createCriteria(Cat.class)
         .createAlias("kittens", "kit")
         .add( Restrictions.like("kit.name", "Iz%") )
         .list();
    

    You’ll notice you can either use an alias and the . notation, or you can use createCriteria with a straight property name.

    However, this example is for the where clause. Not 100% how it would play out for the projections (i.e., if you can have subcriteria with projections). I’d just stick to the alias approach you already have.

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

Sidebar

Related Questions

I have the following code. <s:push value=#session['person']> <s:if test=%{admin=='y'}> <a class=add href=/projit1/project/addProject.jsp>Create a Project</a>
I have following code class User attr_accessor :name end u = User.new u.name =
I have following code snippet that i use to compile class at the run
I have the following code segment in which I'm getting error using (var session
i have the following code using Nhibernate.Linq var apps = Session.Linq<History>().OrderByDescending(r => r.LastUpdated).Take(50); Console.Write(apps.Count());
I have the following nhibernate mapping <class name=Customer> <id name=Id> <generator class=native/> </id> <property
I have the following in my code: if (Session[CurrentUrl] != null) { var ip
I have the following code in the Try bloc : // Session variable Session
Currently I have the following code: switch (publicationType) { case PublicationType.Book: return Session.Query<Publication>() .Where(p
I have the following code: $this->db->from('addresses'); $this->db->where('user_id', $this->session->userdata('user.id')); $this->db->like('country', $pSearch); $this->db->or_like('state', $pSearch); $this->db->or_like('city', $pSearch);

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.