Hernan (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=62fba63...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiODkyZjYyMTVi...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15686?atlOrigin=eyJpIjoiODkyZj...
) HHH-15686 (
https://hibernate.atlassian.net/browse/HHH-15686?atlOrigin=eyJpIjoiODkyZj...
) Envers incorrect key parameter order in insert statement when InheritanceType.JOINED and
@Embeddable ID (
https://hibernate.atlassian.net/browse/HHH-15686?atlOrigin=eyJpIjoiODkyZj...
)
Issue Type: Bug Affects Versions: 6.1.5 Assignee: Chris Cranford (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Components: hibernate-envers Created: 07/Nov/2022 12:38 PM Environment: Hibernate ORM
core version 6.1.5.Final, openjdk version "11" 2018-09-25, Ubuntu 20.04.4 LTS,
SQL Server 2008 R2 (SP3) Priority: Major Reporter: Hernan (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=62fba63...
)
I'm using @Inheritance(strategy = InheritanceType.JOINED) entities with @Audited
annotation on both super and sub class, with multiple attributes in PK (@Embeddable)
When persisting a subclass entity the insert statement in the revision table of the
subclass has incorrect order of parameters versus field list
The simplest code I can build to show the behavior is:
Super class "ServicioTest":
@Entity
@Table(name = "serviciosTest")
@Inheritance(strategy = InheritanceType.JOINED)
@Audited
public class ServicioTest implements Serializable {
@EmbeddedId
private ServicioTestId id;
@Column(name = "srv_cod_Prestacion")
private String cod_prestacion;
@Version
private int version;
Id class "ServicioTestId":
@Embeddable
public class ServicioTestId implements Serializable{
@Column(name = "srv_id")
private Integer id;
private String empresa;
private Integer prr_id;
Subclass "HotelTest":
@Entity
@Table(name = "HotelesTest")
@Audited
public class HotelTest extends ServicioTest {
private String nombreApellido;
persistence.xml (envers related)
<property name="org.hibernate.envers.audit_table_suffix" value="_L"
/>
<property
name="org.hibernate.envers.do_not_audit_optimistic_locking_field" value="false"
/>
<property
name="org.hibernate.envers.revision_on_collection_change" value="false"
/>
Key values using in test : empresa = “TTSV”, prr_id = 805, id (srv_id) = 1
Log lines (after successful tables updates) :
Hibernate: insert into REVINFO (REVTSTMP) values (?)
2022-11-07 16:50:26,341 || TRACE [bind] binding parameter [1] as [BIGINT] -
[1667850626338]
Hibernate: insert into serviciosTest_L (REVTYPE, srv_cod_Prestacion, version, REV,
empresa, srv_id, prr_id) values (?, ?, ?, ?, ?, ?, ?)
2022-11-07 16:50:26,349 || TRACE [bind] binding parameter [2] as [VARCHAR] - [HOTE]
2022-11-07 16:50:26,349 || TRACE [bind] binding parameter [3] as [INTEGER] - [2]
2022-11-07 16:50:26,349 || TRACE [bind] binding parameter [4] as [INTEGER] - [15222]
2022-11-07 16:50:26,349 || TRACE [bind] binding parameter [5] as [VARCHAR] - [TTSV]
2022-11-07 16:50:26,349 || TRACE [bind] binding parameter [6] as [INTEGER] - [1]
2022-11-07 16:50:26,349 || TRACE [bind] binding parameter [7] as [INTEGER] - [805]
Hibernate: insert into HotelesTest_L (nombreApellido, srv_id, prr_id, REV, empresa) values
(?, ?, ?, ?, ?)
2022-11-07 16:50:26,350 || TRACE [bind] binding parameter [1] as [VARCHAR] - [Test]
2022-11-07 16:50:26,350 || TRACE [bind] binding parameter [2] as [INTEGER] - [15222]
2022-11-07 16:50:26,350 || TRACE [bind] binding parameter [3] as [VARCHAR] - [TTSV]
2022-11-07 16:50:26,351 || TRACE [bind] binding parameter [4] as [INTEGER] - [1]
2022-11-07 16:50:26,351 || TRACE [bind] binding parameter [5] as [INTEGER] - [805]
2022-11-07 16:50:26,353 || INFO [AbstractBatchImpl] HHH000010: On release of batch it
still contained JDBC statements
2022-11-07 16:50:26,353 || ERROR [BatchingBatch] HHH000315: Exception executing batch
[com.microsoft.sqlserver.jdbc.SQLServerException: Error de conversión al convertir el
valor varchar 'TTSV' al tipo de datos int.], SQL: insert into HotelesTest_L
(nombreApellido, srv_id, prr_id, REV, empresa) values (?, ?, ?, ?, ?)
2022-11-07 16:50:26,355 || WARN [SqlExceptionHelper] SQL Error: 245, SQLState: S0001
2022-11-07 16:50:26,355 || ERROR [SqlExceptionHelper] Error de conversión al convertir el
valor varchar 'TTSV' al tipo de datos int.
Parameter binding in superclass table is correct, but in subclass is INCORRECT (line 10),
field names change their order compared to previous insert, but parameters keep previous
order
Thanks in advance
(
https://hibernate.atlassian.net/browse/HHH-15686#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15686#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#100210- sha1:4f8bc0d )