Hibernate binds 5th parameter while entity with composite key has only 4

Description

When I try to save entity with composite primary key Hibernate binds 5th parameter while I have only 4.

Steps to reproduce:

This is the trouble entity:

The other related entities:

This is the way I put AssetAssetTypeAttribute in Asset Entity

This is the way I save entities:

Actual result
When Hibernate tries to save AssetAssetTypeAttribute entity, it generate this stuff:

And therefore I got this exception on the Postgresql level:

Expected result
Entities are successfully saved

Environment

None

Activity

Show:
Kirill Antonov
November 19, 2020, 8:44 PM

And I created pull request with test.

In test I get error Invalid value "5" for parameter "parameterIndex".

Kirill Antonov
November 19, 2020, 8:46 PM

And you have a broken link in README.md here

Christian Beikov
November 20, 2020, 9:48 AM

Thanks for the test. I will give it a look later today.

Kirill Antonov
November 21, 2020, 9:55 PM

Noticed that I accidentaly added redundant @Id annotations in test while trying to see behavior. Already removed them from tests and from description.

The strange behavior is still reproducing

Kirill Antonov
November 22, 2020, 11:28 PM

Seems like I found workaround with @Embeddable annotation. Maybe it is more elegant solution for my case. And while debugging I noticed that hibernate ignores “insertable” parameter for column with @Id annotation. It tries to bind all @Id values.

So, workaround itself:

 

Assignee

Unassigned

Reporter

Kirill Antonov

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure