Illegal Update-Statement generated

Description

The following Entities are given

Until Version 5.3.20.Final the following HQL-Statement generates a correct SQL-Update-Statement

session.createQuery("update Nachricht set titel='abc' where sender.id=:pnutzerid ");

Correct generated SQL-Statement is:

After Upgrading to version 5.3.21.Final the same HQL generates the following wrong SQL-Statement

 

Has this change been made deliberately or is it a bug?

A complete example to reproduce the error is attached. Change the hibernate-Version in the pom.xml

Attachments

1

Activity

Show:

Christian Beikov October 11, 2022 at 8:55 AM

You can read the documentation section on the @NotFound annotation which explains why implicit joins like sender.id are treated this way:

Wolfgang Klaus October 11, 2022 at 8:49 AM

Thank you for the clarification.
What is the background of this breaking change? I only want to unterstand it.

Christian Beikov October 11, 2022 at 8:24 AM

I understand that this is unfortunate, but I doubt that you want the semantically correct query:

You will just have to switch to the fk function if you want to access the foreign key column of an association that has a NotFoundAction specified.

Christian Beikov October 11, 2022 at 8:18 AM

This is due to your use of not-found=”ignore” for your many-to-one which tells Hibernate, that the value in the LSENDERID column might not point to an actual row in the PORTALNUTZER table.

Either remove the not-found attribute or change your query to ... where fk(sender) = :pnutzerid.

Rejected

Details

Assignee

Reporter

Worked in

Components

Affects versions

Priority

Created October 11, 2022 at 7:20 AM
Updated October 11, 2022 at 8:55 AM
Resolved October 11, 2022 at 8:24 AM