Douphi (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63217e4...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDFjMmMyMTVm...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15507?atlOrigin=eyJpIjoiZDFjMm...
) HHH-15507 (
https://hibernate.atlassian.net/browse/HHH-15507?atlOrigin=eyJpIjoiZDFjMm...
) AttributeConverter with UUID as binary(16) did not work anymore (
https://hibernate.atlassian.net/browse/HHH-15507?atlOrigin=eyJpIjoiZDFjMm...
)
Issue Type: Bug Assignee: Christian Beikov (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Created: 14/Sep/2022 01:09 AM Priority: Major Reporter: Douphi (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63217e4...
)
Hi,
Since version 5.6.6.Final and probably this change : HHH-15097 (
https://hibernate.atlassian.net/browse/HHH-15097 ) Closed
the AttributeConverter with UUID stored as binary(16) is not used anymore (tested with
Mariadb(10.4) and H2 in reproducer) .
As the AttributeConverter is not executed, insert failed to insert a uuid into the
binary(16).
*Mariadb* :
Insert
Caused by: java.sql.SQLException: Data too long for column
'someValue' at row 1
Same for read, where the binary(16) cannot be translated as UUID.
java.lang.IllegalArgumentException: Invalid UUID string:
F��$:O��zdZ���
*H2* :
Insert
Caused by: org.h2.jdbc.JdbcSQLDataException: Valeur trop longue pour
la colonne "SOMEVALUE BINARY(16)":
"CAST(X'62363564393434652d656636662d346265622d383236332d663966373963376363626136'...
(36)"
Value too long for column "SOMEVALUE BINARY(16)":
"CAST(X'62363564393434652d656636662d346265622d383236332d663966373963376363626136'...
(36)"; SQL statement:
insert into TestEntity (someValue, id) values (?, ?) [22001-214]
Read
java.lang.IllegalArgumentException: Invalid UUID string:
F��$:O��zdZ���
Reproducer : branch main :
https://github.com/douph1/hibernate-test-case-templates (
https://github.com/douph1/hibernate-test-case-templates )
JPAUnitTestCase > HHH15097TestInsert() and HHH15097TestRead()
I think it is related to this fixed VARCHAR
https://github.com/hibernate/hibernate-orm/pull/4860/commits/0ea2c11dff94...
(
https://github.com/hibernate/hibernate-orm/pull/4860/commits/0ea2c11dff94...
)
@Override
public SqlTypeDescriptor getJdbcRecommendedSqlType(JdbcRecommendedSqlTypeMappingContext
context)
{ return context.getTypeConfiguration().getSqlTypeDescriptorRegistry().getDescriptor(
Types.VARCHAR ); }
As stated in the doc the binary is the default storage format for database that don't
handle UUID type.
https://docs.jboss.org/hibernate/orm/5.6/userguide/html_single/Hibernate_...
(
https://docs.jboss.org/hibernate/orm/5.6/userguide/html_single/Hibernate_...
)
The default UUID mapping is the binary one because it uses a more
efficient column storage.
2.3.11. UUID as binary
As mentioned, the default mapping for UUID attributes. Maps the UUID to a byte[] using
>java.util.UUID#getMostSignificantBits and java.util.UUID#getLeastSignificantBits and
stores that as BINARY >data.
Chosen as the default simply because it is generally more efficient from a storage
perspective.
Thanks
(
https://hibernate.atlassian.net/browse/HHH-15507#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15507#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#100207- sha1:c85b1ee )