[JIRA] (HHH-15686) Envers incorrect key parameter order in insert statement when InheritanceType.JOINED and @Embeddable ID
by Hernan (JIRA)
Hernan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=62fba63... ) *commented* on HHH-15686 ( https://hibernate.atlassian.net/browse/HHH-15686?atlOrigin=eyJpIjoiMTlkZT... )
Re: Envers incorrect key parameter order in insert statement when InheritanceType.JOINED and @Embeddable ID ( https://hibernate.atlassian.net/browse/HHH-15686?atlOrigin=eyJpIjoiMTlkZT... )
After debugging the source code I maybe found the problem, the wrong order is apparently generated in class "org.hibernate.mapping.SimpleValue", method "sortColumns"
public void sortColumns(int[] originalOrder) {
if ( columns.size() > 1 ) {
final Selectable[] originalColumns = columns.toArray( new Selectable[0] );
final boolean[] originalInsertability = ArrayHelper.toBooleanArray( insertability );
final boolean[] originalUpdatability = ArrayHelper.toBooleanArray( updatability );
for ( int i = 0; i < originalOrder.length; i++ ) {
final int originalIndex = originalOrder[i];
final Selectable selectable = originalColumns[originalIndex];
if ( selectable instanceof Column ) {
( (Column) selectable ).setTypeIndex( i );
}
columns.set( i, selectable );
insertability.set( i, originalInsertability[originalIndex] );
updatability.set( i, originalUpdatability[originalIndex] );
}
}
}
changing to (diff)
@@ -203,19 +203,19 @@
if ( columns.size() > 1 ) {
final Selectable[] originalColumns = columns.toArray( new Selectable[0] );
final boolean[] originalInsertability = ArrayHelper.toBooleanArray( insertability );
final boolean[] originalUpdatability = ArrayHelper.toBooleanArray( updatability );
for ( int i = 0; i < originalOrder.length; i++ ) {
final int originalIndex = originalOrder[i];
- final Selectable selectable = originalColumns[originalIndex];
+ final Selectable selectable = originalColumns[i];
if ( selectable instanceof Column ) {
( (Column) selectable ).setTypeIndex( i );
}
- columns.set( i, selectable );
- insertability.set( i, originalInsertability[originalIndex] );
- updatability.set( i, originalUpdatability[originalIndex] );
+ columns.set( originalIndex, selectable );
+ insertability.set( originalIndex, originalInsertability[originalIndex] );
+ updatability.set( originalIndex, originalUpdatability[originalIndex] );
}
}
}
works.
Hope that someone that fully understand the code can confirm it is correct.
(And perhaps change de component from "hibernate-envers" to "hibernate-core"?)
Thanks.
( 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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100210- sha1:ffe1a02 )
1 year, 10 months