0

I was reading the Post from user @JB Nizet

Hibernate Exception on MySQL Cross Join Query

Later i have try my own code

I have a HQL like this.

update Student set newField='newField',anotherFieldsToBeUpdated where .... 
and id in
(select s.id from Student s where s.school=:school)
-->[Student->School]many to one relationship....

But still throws the infamous

Caused by: java.sql.SQLException: You can't specify target table 'Student' for update in FROM clause

I was wondering if still exists a solution without using another different select or use a temporal table.

1
  • Can you tell in words what is your query purpose? And what is the relationship between Student and School? Commented Feb 24, 2015 at 16:05

1 Answer 1

1

When you access just one and the same table you can combine your limitation together:

update Student set newField = :newField where ... and school = :school
Sign up to request clarification or add additional context in comments.

1 Comment

Glad I could help. In case you need more info, refer to the HQL specification.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.