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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:02:35+00:00 2026-05-12T17:02:35+00:00

I am facing a problem in Hibernate property formula field – I’m unable to

  • 0

I am facing a problem in Hibernate property formula field – I’m unable to combine both table columns.

shift_id column belongs to the parent table of job_card and duration column belongs to the child table of job_card_idle_time. But it considers both columns as belonging to the parent table of job_card.

<property
    name="utilization"
    formula="(count(shift_id)*340)-sum(duration)/(count(shift_id)*340)"
    generated="never"
    insert="false"
    update="false"
    type="float">
</property>

With the resulting query:

    select (count(this_.shift_id)*340)-sum(**this_.duration**) /(count(this_.shift_id)*340) as y0_,
    this_.JOB_CARD_DATE as y1_ 
    from job_card this_ 
    left outer join job_card_idle_time ir1_ on this_.JOB_CARD_ID=ir1_.JOB_CARD_ID 
    where this_.JOB_CARD_DATE between ? and ? 
    group by this_.JOB_CARD_DATE 
    order by this_.JOB_CARD_DATE desc

I want it as this.

    select (count(this_.shift_id)*340)-sum(**ir1_.duration**)
    /(count(this_.shift_id)*340) as y0_,
     this_.JOB_CARD_DATE as y1_ 
    from job_card this_ 
    left outer join job_card_idle_time ir1_ on this_.JOB_CARD_ID=ir1_.JOB_CARD_ID 
    where this_.JOB_CARD_DATE between ? and ? 
    group by this_.JOB_CARD_DATE 
    order by this_.JOB_CARD_DATE desc

How do I achieve that?

  • 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-12T17:02:35+00:00Added an answer on May 12, 2026 at 5:02 pm

    This type of query is best mapped as, well, query rather than derived property.

    Formula can only contain SQL expression based on columns from current table. The only way to use columns from other tables is to write your formula as sub-select:

    (SELECT count(card.shift_id) * 340 - sum(idleTime.duration) / (count(card.shift_id) * 340)
       FROM job_card card
       LEFT OUTER JOIN job_card_idle_time idleTime on card.job_card_id = idleTime.job_card_id
      WHERE card.shift_id = shift_id)
    

    When you refer to column without an alias it will be prefixed with an alias of your main entity table during query execution. Note, however, that the above will not do what you want because you can’t group within sub-select based on outside criteria. Also, depending on your database left outer join within sub-select may not be supported.

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

Sidebar

Related Questions

I'm facing what I think is a simple problem with Hibernate, but can't solve
When facing the problem of validating a property in a JSF2 application there are
I am facing a problem with parent child type relations. Hibernate docs say to
I am facing problem with hibernate annotations.For the code shown below I have a
Technology Description: Hibernate annotation- 3.4.0.GA java 1.5 table : users_roles_branches columns : user_id, role_id,
Currently We are facing a lot of problem in migrating our Application from Hibernate
i am using hibernate as ORM tool, i am facing one problem, i need
I am facing a strange problem. Without any change, hibernate does not do anything
I'm facing a problem with Hibernate. My current project is a little game. In
I am using separate hbm.xml files for hibernate mappings and facing problem in defining

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.