Holger Bach (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=642158a...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiN2VkMmYzMDc5...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16379?atlOrigin=eyJpIjoiN2VkMm...
) HHH-16379 (
https://hibernate.atlassian.net/browse/HHH-16379?atlOrigin=eyJpIjoiN2VkMm...
) @DynamicUpdate and 'enableDirtyTracking=true' leads to wrong update statement (
https://hibernate.atlassian.net/browse/HHH-16379?atlOrigin=eyJpIjoiN2VkMm...
)
Change By: Holger Bach (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=642158a...
)
When updating an derived entity containing several field, not all changed fields will be
updated
Having a base entity containing two fields named *checksum* and *variantName* and a
derived entity containing one field named *fileSize*.
Create an database entry,
{noformat}FileVersion version = new FileVersion();
version.setId("1");
version.setFileSize(100L);
version.setCheckSumMD5("ABCDEF");
version.setVariantName("A");{noformat}
change all fields of the existing database entry (see testcase *testWithDynamicUpdate*)
{noformat}version.setCheckSumMD5("XXXXXXXX");
version.setVariantName("B");
version.setFileSize(200L);{noformat}
The following update statement will be created
{noformat}Hibernate: update Versionen set CHECKSUM=?, FILESIZE=? where
VERS_NUMMER=?{noformat}
Only *checksum* and *fileSize* will be updated, but not the field *variantName*.
Problem occurs in file *AbstractEntityPersister* in function
*resolveDirtyAttributeIndexes*. ch
The dirty fields will be sorted bei name
{noformat}Arrays.sort( attributeNames );
attributeName = {checkSum, fileSize, variantName}{noformat}
In the for loop the fields in *attributeNames* will be compared to the array
*attributeMappings*, which contains the mapping informations according to the
annotations.
*attributeMappings* has the following order:
{noformat}attributeMappings = {AbstarctVersion.checksum, AbstractVersion.variantName,
FileVersion.fileSize}{noformat}
The for loop does only recognize the fields *checksum* and *fileSize. variantName* will
not be processed.
A sample project with test case can be found
[
here|https://github.com/HoBa1975/hibernate-mapping]
(
https://hibernate.atlassian.net/browse/HHH-16379#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16379#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#100219- sha1:ac3e918 )