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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:04:36+00:00 2026-06-07T17:04:36+00:00

I have 2 entities as PayoutHeader.java @Entity public class PayoutHeader extends GenericDomain implements Serializable

  • 0

I have 2 entities as

PayoutHeader.java

@Entity
public class PayoutHeader extends GenericDomain implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;        
    @Column
    private Integer month;
    @Column
    private Integer year;
    @OneToOne
    private Bank bank;
    @Column
    private Double tdsPercentage;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date **chequeIssuedDate**;

    @Temporal(javax.persistence.TemporalType.DATE)
    private Date entryDate;

}

PayoutDetails .java

@Entity
public class PayoutDetails {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;        

    @ManyToOne
    private PayoutHeader payoutHeader;

    @Column
    private Double amount;
    @Column
    private String bankName;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date clearingDate;
    @OneToOne    
    private Advisor advisor;

    @Column
    private Long **advisorId**;
}

I want to write query using Hibernate Criteria like

Select pd.* from PayoutDetails pd, PayoutHeader ph where pd.payoutheaderId = ph.id and pd.advisorId = 1 and and ph.chequeIssuedDate BETWEEN STR_TO_DATE('01-01-2011', '%d-%m-%Y') AND STR_TO_DATE('31-12-2011', '%d-%m-%Y') ";

I have written query like this

public List<PayoutDetails> getPayoutDetails(AdvisorReportForm advisorReportForm) {
        Criteria criteria = getSession().createCriteria(PayoutDetails.class);

        if (advisorReportForm.getAdvisorId() != null && advisorReportForm.getAdvisorId() > 0) {
            criteria.add(Restrictions.eq("advisorId", advisorReportForm.getAdvisorId().toString()));
        }

        criteria.setFetchMode("PayoutHeader", FetchMode.JOIN)
                .add(Restrictions.between("chequeIssuedDate", advisorReportForm.getFromDate(), advisorReportForm.getToDate()));        

        return criteria.list();
    }

But is giving error as

org.hibernate.QueryException: could not resolve property:
chequeIssuedDate of: org.commission.domain.payout.PayoutDetails

I think is is trying to find chequeIssuedDate field in PayoutDetails, but this field is in PayoutHeader. How to specify alias during join ?

  • 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-07T17:04:39+00:00Added an answer on June 7, 2026 at 5:04 pm

    The criteria.setFetchMode("PayoutHeader", FetchMode.JOIN) just specifies that you want to get the header by a join, and in this case is probably unneeded. It doesn’t change which table is used in the restrictions. For that, you probably want to create an additional criteria or an alias, more or less as follows:

    public List<PayoutDetails> getPayoutDetails(AdvisorReportForm advisorReportForm) {
            Criteria criteria = getSession().createCriteria(PayoutDetails.class);
    
            if (advisorReportForm.getAdvisorId() != null && advisorReportForm.getAdvisorId() > 0) {
                criteria.add(Restrictions.eq("advisorId", advisorReportForm.getAdvisorId().toString()));
            }
    
            criteria.createCriteria("payoutHeader")
                    .add(Restrictions.between("chequeIssuedDate", advisorReportForm.getFromDate(), advisorReportForm.getToDate()));        
    
            return criteria.list();
        }
    

    or (using an alias)

    public List<PayoutDetails> getPayoutDetails(AdvisorReportForm advisorReportForm) {
            Criteria criteria = getSession().createCriteria(PayoutDetails.class);
    
            if (advisorReportForm.getAdvisorId() != null && advisorReportForm.getAdvisorId() > 0) {
                criteria.add(Restrictions.eq("advisorId", advisorReportForm.getAdvisorId().toString()));
            }
    
            criteria.createAlias("payoutHeader", "header")
                    .add(Restrictions.between("header.chequeIssuedDate", advisorReportForm.getFromDate(), advisorReportForm.getToDate()));        
    
            return criteria.list();
        }
    

    See the Hibernate docs on Criteria Queries for examples of this.

    It’s also likely not appropriate to convert the advisorId to a string, as it is in fact a Long and probably mapped to a number field in sql.

    It’s common to also not map something like this advisorId field at all if you map the advisor, and use a restriction based on the advisor field, similarly to the way this deals with the payoutHeader field.

    I wouldn’t worry about getting all the fields from the header, but it may behave a bit differently if you get the createCriteria version to work.

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

Sidebar

Related Questions

I have two entities A and B. public class A{ @Id @GeneratedValue private Integer
If I have entities like: @Entity public class Person { public String name; @OneToMany
I have two entities: Recipe and Ingredient. Entites: public class Ingredient { public int
hey guys, say I have Entities and mappings like this: public class Episode {
I have entities: public class Document : PersistentObjectBase { public virtual long? FolderId {
I am using Entity Framework and DevExpress 10.5 XtraGrid. Imagine that we have entities
I have two entities Visita and Cliente that implements respectively two interfaces IVisita and
I have entities Basket and BasketItem : /** * Acme\BasketBundle\Entity\Basket * * @ORM\Entity(repositoryClass=Acme\BasketBundle\Repository\BasketRepository) *
Say I have entities organized in a hierarchy with Parent being the root entity
I have entities Group and User . the Group entity has Users property which

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.