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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:50:55+00:00 2026-05-22T18:50:55+00:00

@Entity public class Store {} @Entity @Table(name = storeitem) public class StoreItem { @Id

  • 0
@Entity
public class Store {}


@Entity
@Table(name = "storeitem")
public class StoreItem {

    @Id @Column
    private Integer storeId;

    @Id
    @ManyToOne @JoinColumn (name="productId", referencedColumnName="id")
    private Product product;

    @Column private Double cost;
}

mysql> desc storeitem;
+-------------+---------------------+------+-----+---------+-------+
| Field       | Type                | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| StoreId     | int(10) unsigned    | NO   | PRI | 0       |       |
| ProductId   | bigint(20) unsigned | NO   | PRI | 0       |       |
| cost        | double unsigned     | NO   |     | 0       |       |



@Entity
@Table(name = "product")
public class Product {
    @Id @GeneratedValue @Column(name = "Id")
    private Long id;

    @Column(name = "Name")
    private String name;
}

mysql> desc product;
+-------------+---------------------+------+-----+---------+----------------+
| Field       | Type                | Null | Key | Default | Extra          |
+-------------+---------------------+------+-----+---------+----------------+
| Id          | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| Name        | varchar(70)         | NO   |     |         |                |




 Criteria cr=sess.createCriteria(StoreItem.class);
 cr.add(Restrictions.eq("product.name","butter"));
 cr.list();

When i try to filter by child’s property i get this below exception

org.hibernate.QueryException: could not resolve property: product.name of:StoreItem
  • 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-05-22T18:50:56+00:00Added an answer on May 22, 2026 at 6:50 pm

    HQL solved the probelm

    String hql="from StoreItem where productId in (select pd.id from Product pd where name = 'butter')";
    Query query=sess.createQuery(hql);
    query.list();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

@Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Problem { @ManyToOne private Person person; } @Entity
I have the following entity structure: public class Party { public Int32 PartyId {
Using NHibernate.Mapping.Attributes, I have a entity class with something like: [Class] public class EntityA
I have the following entity class (in Groovy): import javax.persistence.Entity import javax.persistence.Id import javax.persistence.GeneratedValue
I have an entity that maps to an external oracle table which is one
Entity framework provides great flexibility to update data in the same datacontext Dim personA
I'm using Entity Framework O/R mapper from Microsoft and using entity classes (generated classes
We use a base entity with properties such as version (datetime needed for NHibernate)
I've created an Entity Data Model and imported several stored procedures as Function Imports.
I've built a entity framework model against a 2008 database. All works ok against

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.