AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Hibernate uuid generator3/16/2023 ![]() The first thing we need to do is generate the UUID. I’ll go step by step explaining why we add each piece of code. Now let’s talk about how we can implement this. If you’re still on the fence here’s a great article talking about the pros and cons of using UUIDs as primary keys. What’s easier to remember: 223492 or 453bd9d7-83c0-47fb-b42e-0ab045b29f83 ? This is specially true if you happen to be exposing your ids on your public APIs. You might think Id space is not a big deal, but consider that Primary Keys are often used in indexes and as Foreign Keys on other tables. Specially if you make the mistake of storing it as a String. ![]() As you can imagine storing an UUID takes a lot more space than storying an Int. So here are some of the downsides of using UUIDss for you to consider: This lets us model our entities as immutable objects and we avoid having to handle null values on the id.īut as you probably already know: □□□.
0 Comments
Read More
Leave a Reply. |