[ad_1]
I am trying to execute the following query in JPA via a native query with my MSSQL DB:
@Modifying
@Query(
value = "update dbName.DQM set OverallScore= :overallScore, " +
"CompletenessScore= :completenessScore, UniquenessScore= :uniquenessScore " +
"where ColumnId = :columnId " +
"IF @@ROWCOUNT=0 " +
"insert into dbName.DQM (Id, DataSourceId, DatabaseId, TableId, ColumnId, OverallScore, " +
"CompletenessScore, UniquenessScore, Version, CreatedBy, CreateDT) " +
"values( " +
"NEWID(), " +
":datasourceId, " +
":databaseId, " +
":tableId, " +
":columnId, " +
":overallScore, " +
":completenessScore, " +
":uniquenessScore, " +
":version, " +
":createdBy, " +
"CURRENT_TIMESTAMP " +
")",
nativeQuery = true
)
void upsertDQM(UUID datasourceId, UUID databaseId, UUID tableId, UUID columnId, double overallScore, double completenessScore, double uniquenessScore, long version, UUID createdBy);
And when passing the UUID, the binaries get switched up. An example of this would be if I pass in UUID 1 as a @PathVariable. It will register in the service method BEFORE saving in the insert as it’s appropriate value, ‘0a0303d8-e816-6c44-9aca-a0204a07a9e1’. However, after inserting, it saved into the database as UUID 2. And UUID 1 and UUID 2 have the same binaries in a switched order, as shown/displayed below:
UUID 1 ==> 0a0303d8-e816-6c44-9aca-a0204a07a9e1
UUID 2 ==> d803030a-16e8-446c-9aca-a0204a07a9e1
The last part is the exact same —> -9aca-a0204a07a9e1
And the first part of each:
0a –> 03 –> 03 –>d8 | e8 –> 16 | 6c –> 44
d8 –> 03 –> 03 –>0a | 16 –> e8 | 44 –> 6c
When I change the type from UUID to a String in Java, it saves appropriately in MSSQL as the correct uniqueidentifier so I do have an alright workaround, but I could not find in google a solid reason as to why this is happening. Has anyone ever ran into this or does anyone know why JPA or a native query would behave this way? Thank you for your time
[ad_2]