Spring Data cannot fetch a record using UUID in postgresql
I'm using Hibernate 5.3.11 and had the same problem. Thanks to the answer Luca Basso Ricci in 'FindByUUID() using Spring Data's JPA Repository' it was fixed.
The solution (for me) was adding the following annotation to the UUID field:
import org.hibernate.annotations.Type
...
@Type(type="org.hibernate.type.UUIDCharType")
private UUID uuid;
The Parameter value [12345678-1234-1234-1234-123456789012] did not match expected type [java.util.UUID (n/a)]
error means that value read from the database failed to map to the corresponding field type.
See HHH-9562 Dialect specific UUID handling which improved UUID handling in Hibernate 5. Your problem might be solvable with @Column(columnDefinition = "uuid", updatable = false)
annotation.
@Id
@Column(columnDefinition = "uuid", updatable = false)
@GeneratedValue(generator = "uuid")
@GenericGenerator(
name = "uuid",
strategy = "com.mypackage.UUIDGenerator",
parameters = {
@Parameter(
name = UUID_NAMESPACE,
value = "something"
)
}
)
private UUID id;
If you need to debug it further check PostgreSQL Dialect class that you configured in your code and ensure that field definition in your entity correctly declares PostgreSQL UUID column type. There have been a number of issues with UUID e.g. HHH-9577.