![]() If you try to insert into a UUID column using a, you’ll get an error saying: “ERROR: column "studentid" is of type uuid but expression is of type bytea.” To circumvent this, many people cut corners by simply defining their UUID columns as TEXT, and just use Java String objects to get the job done. ![]() The challenge, however, is that when using JPA, it’s not trivial to manipulate UUIDs, as your Entity definitions require strict mapping of data types. Not only that, the UUID type has built-in validation to ensure that you have the correct 8-4-4-4-12 formatting. Text size (in bytes) | uuid size (in bytes) But keep in mind that the UUID type is constrained to 16 bytes, whereas the TEXT type will be more than double the size: Now, you may ask, “Why should I care so much about storing UUIDs as a UUID type in Postgres? Wouldn’t it be simpler to store UUIDs as TEXT or VARCHAR types?” Well, yes, that may be true. ![]() Enterprise-ready Postgres tools for high availability, monitoring, and disaster recovery.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |