Akshaya Gawand (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6409b5d...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOGMwZDE0Nzk4...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16274?atlOrigin=eyJpIjoiOGMwZD...
) HHH-16274 (
https://hibernate.atlassian.net/browse/HHH-16274?atlOrigin=eyJpIjoiOGMwZD...
) Incorrect binding @OneToMany with multiple join columns (
https://hibernate.atlassian.net/browse/HHH-16274?atlOrigin=eyJpIjoiOGMwZD...
)
Issue Type: Bug Assignee: Unassigned Created: 09/Mar/2023 03:15 AM Environment: Using
spring-boot-jpa:3.0.2 which uses Hibernate ORM core version 6.1.6.Final
Priority: Major Reporter: Akshaya Gawand (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6409b5d...
)
Following is my entity class where I am using @OneToMany (
https://github.com/OneToMany )
annotation, which leads to incorrect binding. ref_no and seq_no are my binding parameters.
But the binding values are out of order. Value for ref_no binds with seq_no and value for
seq_no binds with ref_no.
@OneToMany(fetch = EAGER)
@JoinColumns({
@JoinColumn(name = "REF_NO",referencedColumnName =
"REF_NO"),
@JoinColumn(name = "SEQ_NO",referencedColumnName =
"SEQ_NO")
})
public Set<InProcessPartyEntity> getParties() {
return parties;
}
Output trace log(incorrect binding):
Hibernate: select p1_0.seq_no,p1_0.ref_no,p1_0.party_code,p1_0.party_id from
rbi_trade.ot_txn_party p1_0 where (p1_0. *seq_no* ,p1_0. *ref_no* ) in((?,?))
2023-03-09T08:31:42.540+01:00 TRACE 15588 — [ scheduling-1] org.hibernate.orm.jdbc.bind :
binding parameter [1] as [VARCHAR] - [*E313100005323221237*] 2023-03-09T08:31:42.540+01:00
TRACE 15588 — [ scheduling-1] org.hibernate.orm.jdbc.bind : binding parameter [2] as
[VARCHAR] - [*001*]
In the same entity class I am also using @OnetoOne (
https://github.com/OnetoOne )
annotation with multiple join columns as follows, which works perfectly fine and leads to
the correct binding parameters values
`
@OneToOne(fetch = EAGER)
@JoinColumns({
@JoinColumn(name = "REF_NO",referencedColumnName =
"REF_NO"),
@JoinColumn(name = "SEQ_NO",referencedColumnName =
"SEQ_NO")
})
public InProcessWorkUnitEntity getWorkUnit() {
return workUnit;
}
Output trace log (correct binding):
Hibernate: select i1_0.ref_no,i1_0.seq_no,i1_0.reg_by from rbi_trade.ot_workunit i1_0
where (i1_0. *ref_no* ,i1_0. *seq_no* ) in((?,?)) 2023-03-09T08:31:42.524+01:00 TRACE
15588 — [ scheduling-1] org.hibernate.orm.jdbc.bind : binding parameter [1] as [VARCHAR] -
[*E313100005323221237*]
2023-03-09T08:31:42.525+01:00 TRACE 15588 — [ scheduling-1] org.hibernate.orm.jdbc.bind :
binding parameter [2] as [VARCHAR] - [*001*]
I am facing this issue since I upgraded to spring boot jpa 3.0.2. I was using version
2.7.2 before where the binds with @OneToMany (
https://github.com/OneToMany ) also worked
fine.
(
https://hibernate.atlassian.net/browse/HHH-16274#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16274#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:e5bf00f )