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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:14:37+00:00 2026-05-10T19:14:37+00:00

I’m trying to convert the below SQL query to HQL and am having a

  • 0

I’m trying to convert the below SQL query to HQL and am having a few issues. A straight line by line conversion doesn’t work, I am wondering if I should be using an Inner Join in the HQL?

        SELECT (UNIX_TIMESTAMP(cosc1.change_date) - UNIX_TIMESTAMP(cosc2.change_date))          FROM customer_order_state_change cosc1           LEFT JOIN customer_order_state cos1_new on cosc1.new_state_id = cos1_new.customer_order_state_id           LEFT JOIN customer_order_state cos1_old on cosc1.old_state_id = cos1_old.customer_order_state_id           LEFT JOIN customer_order_state_change cosc2 on cosc2.customer_order_id = cosc1.customer_order_id           LEFT JOIN customer_order_state cos2_new on cosc2.new_state_id = cos2_new.customer_order_state_id           LEFT JOIN customer_order_state cos2_old on cosc2.old_state_id = cos2_old.customer_order_state_id          WHERE cos1_new.name = 'state1' AND  cos2_new.name = 'state2' and cosc2.change_date < '2008-11-06 09:00'  AND cosc2.change_date > '2008-11-06 06:00' GROUP BY cosc1.change_date, cosc2.change_date ; 

Query returns time in seconds between state changes for a customer order.

The state names and dates are dynamically inserted into the query.

Edit: Just tried this

'SELECT (UNIX_TIMESTAMP(cosc1.changeDate) - UNIX_TIMESTAMP(cosc2.changeDate))' +          ' FROM' +          ' ' + CustomerOrderStateChange.class.getName() + ' as cosc1' +         ' INNER JOIN ' + CustomerOrderStateChange.class.getName() +  ' as cosc2' +         ' WHERE cosc1.newState.name = ?' +         ' AND cosc1.order.id = cosc2.order.id' +          ' AND cosc2.newState.name = ?' +         ' AND cosc2.changeDate < ?' +         ' AND cosc2.changeDate > ?' +          ' GROUP BY cosc1.changeDate, cosc2.changeDate'; 

and received exception’outer or full join must be followed by path expression‘

  • 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. 2026-05-10T19:14:38+00:00Added an answer on May 10, 2026 at 7:14 pm

    Typically you HQL joins are specified using the property on the object, eg, if class Foo and Bar and Foo.bar is of type Bar, then from Foo f inner join f.bar as b is the join. As far as I know, there’s no way of performing a self-join in HQL (I could be wrong here).

    That said, Hibernate allows you to write (slightly enhanced) SQL queries with session.createSQLQuery(...).

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

Sidebar

Ask A Question

Stats

  • Questions 103k
  • Answers 103k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Ensure that all your CS files are within the same… May 11, 2026 at 8:26 pm
  • Editorial Team
    Editorial Team added an answer It just hooks up a local web server to your… May 11, 2026 at 8:26 pm
  • Editorial Team
    Editorial Team added an answer You can start here : http://www.graniteds.org/confluence/display/DOC/2.+Gas3+Code+Generator May 11, 2026 at 8:26 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.