DB2iDialect generates invalid SQL when calling merge on an entity

Hello,

We are using the DB2iDialect to connect to an IBMi system (jdbc:as400)

Since upgrading to Hibernate 6.6.36.Final - straight from 6.5 because we were waiting for a bug fix - we noticed that the following methods are failing and creating invalid SQL:

  • EntityManager → merge
  • JpaRepository → save

This happens when using composite keys (via @EmbeddedId) resulting in these errors:

[SQL0584] NULL or parameter marker in VALUES not allowed.

org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement [[SQL0584] NULL or parameter marker in VALUES not allowed.] [select cua1_0.id_column1,cua1_0.id_column2,cua1_0.column3,cua1_0.column4 from some_table cua1_0 where (cua1_0.id_column1,cua1_0.id_column2) in (select v_.c0,v_.c1 from (values (?,?)) v_(c0,c1))]; SQL [select cua1_0.id_column1,cua1_0.id_column2,cua1_0.column3,cua1_0.column4 from some_table cua1_0 where (cua1_0.id_column1,cua1_0.id_column2) in (select v_.c0,v_.c1 from (values (?,?)) v_(c0,c1))]

Unfortunately, I cannot provide a small repo to reproduce this issue because I can only run on a physical mainframe, and the Docker images I’ve found won’t start.

Fortunately, this may be clear and simple enough to understand the cause and the moment and the reason it started to change.

To your knowledge, is there any workaround besides using update queries?

Let me know if you want me to create a bug ticket on your Jira.

Please see Db2 for i regression in 6.6.30+ (HHH-19768 / row-value IN) – SQL0216 and SQL0584 on basic loads where this problem was already reported.

1 Like

Can you please build this PR and tell us if that fixes your problem?

Hello,

During an upgrade of Hibernate from 6.5.3.Final to 6.6.38.Final (and now try 6.6.41.Final), I found that bug on DB2.

For the moment, I found this problem on select queries which used some field of composite primary key with annotation @EmbeddedId

I’m sorry, but I have no idea what you’re trying to say. The fix is included in 6.6.41.Final, so not sure why you’re trying to upgrade to an old fix version when there is a newer one available.

Sorry to disturb you. I used an old and deprecated dialect (DB2400Dialect). All works in 6.6.41.Final with the correct dialect (DB2iDialect).

Hello @beikov I’m really sorry that I missed your reply. We have been using 6.6.41 since last week and our problems are resolved, thank you!