uuid

What's your opinion on using UUIDs as database row identifiers, particularly in web apps?

混江龙づ霸主 提交于 2019-11-27 09:18:53
问题 I've always preferred to use long integers as primary keys in databases, for simplicity and (assumed) speed. But when using a REST or Rails-like URL scheme for object instances, I'd then end up with URLs like this: http://example.com/user/783 And then the assumption is that there are also users with IDs of 782, 781, ..., 2, and 1. Assuming that the web app in question is secure enough to prevent people entering other numbers to view other users without authorization, a simple sequentially

Hibernate UUID with PostgreSQL and SQL Server

耗尽温柔 提交于 2019-11-27 08:02:41
问题 I have an application I would like to run on both PostgreSQL and SQL Server. I would like to use java.util.UUID as the IDs. I have defined my columns in SQL Server as id UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL UNIQUE I have defined my columns in PostgreSQL as id UUID NOT NULL The columns are defined in my JPA Entities as @Id @Column(name = "id") public UUID getId() { return id; } This works for PostgreSQL as it passes the UUID to the PostgreSQL JDBC driver. This sort of works for SQL Server, as

PHP preg_match UUID v4

て烟熏妆下的殇ゞ 提交于 2019-11-27 07:56:37
问题 I've got a string that contains UUID v4 $uuid = 'http://domain.com/images/123/b85066fc-248f-4ea9-b13d-0858dbf4efc1_small.jpg'; How would i get the b85066fc-248f-4ea9-b13d-0858dbf4efc1 value from the above using preg_match() ? More info on UUID v4 can be be found here 回答1: $uuid = 'http://domain.com/images/123/b85066fc-248f-4ea9-b13d-0858dbf4efc1_small.jpg'; preg_match('!/images/\d+/([a-z0-9\-]*)_!i', $uuid, $m); And preg_match('/[a-f0-9]{8}\-[a-f0-9]{4}\-4[a-f0-9]{3}\-(8|9|a|b)[a-f0-9]{3‌​}\-

Persisting UUID in PostgreSQL using JPA

馋奶兔 提交于 2019-11-27 07:36:58
I'm trying to persist an entity in PostgreSQL that uses UUID as primary key. I've tried persisting it as a plain UUID: @Id @Column(name = "customer_id") private UUID id; With the above, I get this error: ERROR: column "customer_id" is of type uuid but expression is of type bytea Hint: You will need to rewrite or cast the expression. Position: 137 I also tried persisting the UUID as byte[] to no avail: @Transient private UUID id; @Id @Column(name = "customer_id") @Access(AccessType.PROPERTY) @Lob protected byte[] getRowId() { return id.toString().getBytes(); } protected void setRowId(byte[]

What range of Bluetooth UUIDs can be used for vendor defined profiles?

青春壹個敷衍的年華 提交于 2019-11-27 07:29:42
I want to build a simple Bluetooth Low Energy -based application using a custom profile. The adopted profiles / services / characteristics / descriptors use 16-bit UUIDs as seen on the official site . The 16-bit UUIDs are shortcuts for a corresponding 128-bit UUID and is translated as 128-bit UUID = 16-bit Attribute UUID * 2^96 + Bluetooth_Base_UUID with Bluetooth_Base_UUID being 00000000-0000-1000-8000-00805F9B34FB . (Source: Bluetooth Core Specification Vol 3 Part F Section 3.2.1) Since I am using a custom profile, I'm wondering what UUIDs I am allowed to use. Which range of 128-bit UUIDs

Generate UUID values by default for each row on column of UUID type in H2 Database Engine

让人想犯罪 __ 提交于 2019-11-27 06:21:05
问题 In the H2 database, on a table with a column of UUID data type, how do we specify that we want H2 to generate a UUID value by default when an INSERT omits that field? I know how to generate a UUID. I have read the Question, How to insert a specific UUID in h2 database?. My question is about how to ask H2 to generate the UUID value on my behalf. 回答1: You can use built-in function RANDOM_UUID(): create table test(id int primary key, data uuid default random_uuid()); insert into test(id) values

Collisions when generating UUIDs in JavaScript?

情到浓时终转凉″ 提交于 2019-11-27 06:08:17
This relates to this question . I am using this answer to generate UUID in JavaScript: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); return v.toString(16); }); This solution appeared to be working fine, however i am getting collisions. Here's what i have: A web-app running in Google Chrome. 16 users. about 4000 UUIDs have been generated in the past 2 months by these users. i got about 20 collisions - e.g. new UUID genereated today was the same as about 2 months ago (different user). So the questions are: What's

Is there a way to generate a random UUID, which consists only of numbers?

时间秒杀一切 提交于 2019-11-27 05:54:09
问题 Java's UUID class generates a random UUID. But this consists of alphabets and numbers. For some applications we need only numbers. Is there a way to generate random UUID that consists of only numbers in Java ? UUID.randomUUID(); 回答1: If you dont want a random number, but an UUID with numbers only use: String lUUID = String.format("%040d", new BigInteger(UUID.randomUUID().toString().replace("-", ""), 16)); in this case left padded to 40 zeros... results for: UUID : b55081fa-9cd1-48c2-95d4

Which UUID version to use?

a 夏天 提交于 2019-11-27 05:50:01
Which version of the UUID should you use? I saw a lot of threads explaining what each version entails, but I am having trouble figuring out what's best for what applications. There are two different ways of generating a UUID. If you just need a unique ID, you want a version 1 or version 4. Version 1: This generates a unique ID based on a network card MAC address and a timer. These IDs are easy to predict (given one, I might be able to guess another one) and can be traced back to your network card. It's not recommended to create these. Version 4: These are generated from random (or pseudo

Store UUID v4 in MySQL

隐身守侯 提交于 2019-11-27 05:44:40
问题 I'm generating UUIDs using PHP, per the function found here Now I want to store that in a MySQL database. What is the best/most efficient MySQL field format for storing UUID v4? I currently have varchar(256), but I'm pretty sure that's much larger than necessary. I've found lots of almost-answers, but they're generally ambiguous about what form of UUID they're referring to, so I'm asking for the specific format. 回答1: Store it as VARCHAR(36) if you're looking to have an exact fit, or VARCHAR