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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:34:59+00:00 2026-05-20T18:34:59+00:00

When hibernate parses out this hql: UPDATE VERSIONED Person SET groupsCount = followingGroup.size WHERE

  • 0

When hibernate parses out this hql:

UPDATE VERSIONED Person SET groupsCount = followingGroup.size WHERE id = :id

it generates this sql:

UPDATE Person
  SET version  =version+1,
  groupsCount=
  (SELECT COUNT(followingg1_.followerId)
     FROM GroupFollower followingg1_
    WHERE Person.id=followingg1_.followerId
  )-1
  WHERE id IN
  (SELECT groupfollo2_.followerId
     FROM GroupFollower groupfollo2_
    WHERE groupfollo2_.followingId=?
  )

That query fails at the “-1” after the subquery for the count of the followingids. If i take out the “-1” it runs just fine, or if i move the “-1” to “SELECT COUNT(followingg1_.followerId) – 1” it also works.

I don’t see how to work around this, short of using db specific sql, is this a bug with 11g?

  • 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-20T18:35:00+00:00Added an answer on May 20, 2026 at 6:35 pm

    Ok, i found the problem, I was wrong, that statement deals with a “Person” object, which is more complicated that I first realized, although it was at that line that the test was failing, it was actually hql in the class it was testing that produced the sql that was the problem.

    UPDATE VERSIONED Person SET groupsCount = followingGroup.size - 1 WHERE id IN (SELECT etc...)
    

    So that answers the first part, the second part of the answer is that its a known bug apparently in oracle 10g that you can’t do arithmetic operations after the subquery in an update statement (duh!) so changing the above to

    UPDATE VERSIONED Person SET groupsCount = - 1 + followingGroup.size WHERE id IN (SELECT etc...)
    

    works just fine. phew-

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

Sidebar

Related Questions

Hibernate internally uses PreparedStatements under JDBC when converting HQL to SQL. How are inline
I am using Hibernate and I have this query: List<Person> list = sess.createQuery(from Person).list();
So Hibernate Supports the latest Version of Firebird, which is really great. But... I
I had set up hibernate plugin to NetBeans and can not connect to MySQL
I am trying to drop the temp table using hibernate native SQL (createSQLQuery) statement.
I have the following mapping: <?xml version='1.0' encoding='utf-8'?> <hibernate-mapping assembly='Core' namespace='Core.Models' xmlns='urn:nhibernate-mapping-2.2'> <class name='Basket'>
I am attempting to split out the Hibernate DAO and Model Object layer from
The following (simplified version of our) code passes our JUnit tests under Hibernate, but
Hibernate 3.3 If I've got code that is dynamically creating hibernate hql queries like
I try to executer bulk delete using Hibernate HQL query, following reference manunal but

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.