Skip to content

Tag: uuid

Difference between generating UUID in Java and MySQL

I need to insert random id into one table and add that id to another table as foreign key. So I am not sure how to save UUID() if I generated it in MySQL but if I generate it in Java I can just save it into a variable. I wonder are there any drawbacks if I generate it in

Why is UUID#compareTo incompatible with RFC 4122?

Overview Javas UUID class implements Comparable. But the order it implements appears to be incompatible with the specificiation given in RFC 4122. In particular, it is inconsistent with the natural order implied by its string representation (uuid1.toString().compareTo(uuid2.toString())), which lines up with the RFC. Example You can reproduce and observe the problem by using the following code: Details My main problem

@ResponseBody returns empty object

When I use below to get the user object it works just fine. Above gives me a response back as: Now, I am trying to search based on UUID(4) using this: This doesn’t return anything. No error, no warning whatsoever. While this gives me all the details I need: This is what I have in my Repository and Entity Question:

Asserting UUID in junit

I have a method which builds an object and returns it. The object as UUID as one of its fields. While building the object, random UUID is generated. Here is the code: Here is my test: I’m just verifying if the correlationId is not null or not. Is there a better way to verify the UUID? Answer The only way

Storing UUID as string in mysql using JPA

I came across a blog of using UUID with Hibernate and MySql. Now the problem is, whenever I take a look at the database the ID’s will be non-readable format (binary-16). How can I store UUID as a readable format like 7feb24af-fc38-44de-bc38-04defc3804fe instead of ¡7ôáßEN¹º}ÅÑs I was using this code And the result is ¡7ôáßEN¹º}ÅÑs. But I want it as

How to get a computer specific ID number using Java

I want to create an UUID hash using a machine specific ID number other than the MAC address to validate the computer which runs the java application on. Is it possible using Java 1.8? If so, what is the best option I can choose? It would be more helpful if it will be used for both Windows and Unix platforms.

What namespace does the JDK use to generate a UUID with nameUUIDFromBytes?

The Sun/Oracle JDK exposes a function to create a type 3 (name based) UUID in the java.util package: java.util.UUID.nameUUIDFromBytes(byte[] name). I need to be able to generate a type 3 UUID in Java using nameUUIDFromBytes and arrive at the same UUID when creating a type 3 UUID in another language, assuming I provide the same bytes as the source. According