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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:35:22+00:00 2026-05-22T23:35:22+00:00

using Hibernate, I’d like to update a data in the database based on conditions,

  • 0

using Hibernate, I’d like to update a data in the database based on conditions, but I got the following error : “node to traverse cannot be null”

Here is my database description :

Account: id, email, password
Member : id, account, team
Team: id, current (and a reference to member => members)

Here is my JPA :

UPDATE Team t SET t.current = :current LEFT JOIN t.members m WHERE t.current = :current_true AND m.account = :account

What am I doing wrong?
If i move the LEFT JOIN to before the SET :

UPDATE Team t LEFT JOIN t.members m SET t.current = :current WHERE t.current = :current_true AND m.account = :account

I got : “expecting SET, found LEFT”

If I remove the join :

UPDATE Team t SET t.current = :current WHERE t.current = :current_true AND t.members.account = :account

I got : “Illegal attempt to dereference collection”.

What is the correct way to update values ?

Thanks for your help!

  • 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-22T23:35:23+00:00Added an answer on May 22, 2026 at 11:35 pm

    The JPA 2.0 specification in chapter 4 contains details of all supported features in JPQL. This is the definition of the “update” statement:

    The syntax of these operations is as follows:

    update_statement ::= update_clause [where_clause]
     update_clause ::= UPDATE entity_name [[AS] identification_variable] 
                         SET update_item {, update_item}*
      update_item ::= [identification_variable.]{state_field | single_valued_object_field} =
                         new_value 
    new_value ::= 
       scalar_expression |
       simple_entity_expression |
       NULL
    

    As you can see, support for multiple entities is not stated here. I guess you will have to find a different way to do it, perhaps create a method that selects the entities that you want to update first, and then iterate over the results setting the values. Or you could use a native SQL update.

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

Sidebar

Related Questions

I'm using Hibernate to retrieve some data from a database. The result set returned
I am using Hibernate in a Java application to access my Database and it
I'm using Hibernate for ORM of my Java app to an Oracle database (not
We are using Hibernate 3.1 with Spring MVC 2.0. Our problem occurs when data
I've been using Hibernate for years and never have a problem with it, but
I'm using Hibernate 3.6 but would prefer to stick to JPA annotations if possible.
I am using Hibernate, trying to simulate 2 concurrent update to the same row
I've been using Hibernate for a few years but have only used it with
im using hibernate xml to map my databse, but i didn't knew how to
I am using Hibernate 3.0 in my application with Postgres database. It is a

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.