Some articles claimed to avoid equals( and hence hashcode ) troubles when using JPA it's need to use UUID when Id generated is used, like:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
Since RESTful services and Spring Data ( and hence @Entity -ies) are tightly coupled, the reasonable question is:
what is the best practice for using such resource URL: the RESTful services standards claims {Id}-s
in URLs but UUID is something cumbersome to see it in URLs.
So what is the best practice to solve it?
( or may be I'm wrong, and there is nothing bad in numbers like:b5607d38-8fc1-43ef-b44e-34967083c80a
at URLs?)
there is nothing bad in numbers like:b5607d38-8fc1-43ef-b44e-34967083c80a at URLs
This; there's nothing wrong with including a UUID in a URL.
URI/URL rules are defined by RFC 3986. Letters, digits, and -
are all "unreserved" characters, meaning that they can be used anywhere you would expect in a URI.
In REST, identifiers are opaque. Clients and general purpose components are not expected to extract any semantic information from the identifier itself. This gives the server the freedom to encode into its own identifiers any information that it needs to.
/b5607d38-8fc1-43ef-b44e-34967083c80a
is a perfectly fine identifier for a resource.