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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:08:46+00:00 2026-06-06T19:08:46+00:00

weirdly I cannot find something simple about this, I’ve got 2 entity, one inside

  • 0

weirdly I cannot find something simple about this, I’ve got 2 entity, one inside an other and my question is how can I access a property from the sub-entity?

entity 1

@Getter
@Setter
@Entity
public class ObjectA{
    String name;
    String surname;
    ObjectB B;
}

entity 2

@Setter
@Getter
@Entity
ObjectB{
    String family;
    String range;
}

what I want is to access familly and range with a criteria search, so I made this :

public List<ObjectA> search(String name, String surname, String family, String range) {
    Criteria c = HibernateUtil.getSessionFactory().getCurrentSession().createCriteria(ObjectA.class, "a");

if (!name.equals("")) {
    c.add(Restrictions.eq("a.name", name));
}
if (!surname.equals("")) {
    c.add(Restrictions.eq("a.surname", surname));
}
if (!family.equals("")) {
    c.add(Restrictions.eq("a.B.family", family));
}
if (!range.equals("")) {
    c.add(Restrictions.eq("a.B.range", range));
}
return c.list();

}

name and surname can be accessed but family and range cannot.
‘could not resolve property’
What should I do?

thanks =D

  • 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-06T19:08:47+00:00Added an answer on June 6, 2026 at 7:08 pm

    You have to create an alias for the subclass property to be able to access it.

    Take a look at section 15.4 of the following manual http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/querycriteria.html

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

Sidebar

Related Questions

I know the question is a little weirdly stated, but I can't think of
Weirdly, I've never come across this issue before, but I've just started making a
I have this weirdly formatted URL. I have to extract the contents in '()'.
Why is this happening: As you can see, in the Allowed Toolbar Items the
Real odd one to get stuck on but weirdly I am. You you have
I have this layout, and it's scaled weirdly (probably due to inadviseable layout nesting)
I have a strange problem in an IF inside a mysql_fetch_array that works weirdly
One tantalizing shortcoming of Emacs is its weirdly broken scrolling mechanism on 'inertia-scrolling' OSX.
Weirdly, the index page of my Magento commerce is very slow. While you navigate
My project has weirdly started failing with no error messages. Ive tried cleaning the

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.