1 answer
Hello,
You can generate a UUID with Java, insert it into the database, and use it to retrieve the auto-increment.
See: https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/util/UUID.html
--
Trust does not exclude control.
You can generate a UUID with Java, insert it into the database, and use it to retrieve the auto-increment.
See: https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/util/UUID.html
--
Trust does not exclude control.
Thank you for your intervention. I took a quick look, and if I understood correctly, it's like I'm generating 2 keys (the generator's key + the UUID key) only to end up retrieving just one of them. From what I have seen, the key generated by the UUID is 4 times larger (128 bits) than a primitive integer type, so I question the legitimacy of its use, especially in my "context." The exercise I was trying to do was more about directly retrieving the generator's ID from the database and sending it back. However, I'm not sure if there are any methods in the UUID class that allow, among other things, the direct retrieval of the generator's ID, as if it works like a ResultSet. Thank you again for the time you dedicated.
And yes, the UUID is very large, but it is unique among all other UUIDs in the world, whereas your auto-incremented ID is only unique to your database instance.