uuid

Why does PyMongo encode uuid.uuid1() as a BSON::Binary?

巧了我就是萌 提交于 2019-12-24 04:09:36
问题 I'm adding a 'GUID' key with a value of uuid.uuid1() (from python uuid module) for all my documents in Mongo. I noticed they are being stored not as strings, but as type BSON::Binary . I've done some Googling already, but I still don't understand what the purpose/advantage to this serialization is. Can someone explain? Should I be converting the uuid.uuid1() to strings before storing? How can I use a string to find() by the GUID value like db.myCol.find({ 'GUID' : aString })? 回答1: The default

NSUUID duplication chance form different device.

北城余情 提交于 2019-12-24 01:19:45
问题 I need to generate Unique ID for the device when the application installed, and store this value on the device, then need to communicate with server using this UUID. And it seems NSSUUD suit for the sitiation, but I am confused is there any chance of duplication of the UUID from multiple device. I already found the answer https://stackoverflow.com/a/6963990/1573209 where it describe that the version 1 type uses MAC address and 60 bit clock to generate UUID, so the duplication chance is

laravel uuid not showing in query

为君一笑 提交于 2019-12-24 01:01:27
问题 I've a postgres database table that uses uuid's as its primary key, via the webpatser/laravel-uuid package, and 'readable' web ids via vinkla/hashids . When I query the database, if I dd() the response, I see the UUID in full, but if I simply return , I instead get an integer. Presume I've overlooking something obvious, so: Migration $table->uuid('id'); $table->string('web_id'); $table->primary('id'); Model public function store() { $data = [ 'id' => Uuid::generate(4)->string, 'web_id' =>

Problem obtaining entities with uniqueidentifier primary key

末鹿安然 提交于 2019-12-24 00:47:06
问题 In order to investigate whether Hibernate's behavior is different than NHibernate's for a particular usage scenario, I began writing a Java SE & Hibernate port of the relevant parts of my NHibernate-based application, but encountered a problem with obtaining an entity where the corresponding SQL Server 2008 R2 Express table uses a uniqueidentifier for the primary key. Here's the mapping file: <!-- User.hbm.xml --> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-/

UUID in Swift3, but “version 1” style UUID

五迷三道 提交于 2019-12-23 20:52:38
问题 This question is about Swift . It's very easy to generate a rfc UUID in Swift getting a Swift String as at this stage Apple have made a Swift method for it... func sfUUID()->String { return UUID().uuidString.lowercased() } I need an old-style "version 1" UUID, when using Swift (Example: https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_.28date-time_and_MAC_address.29) Is there a way to do this in Swift3 ? ( >9 only) In Swift , how to get a Version 1 UUID. So, there might

MySQL adding dashes to UUID in a table

青春壹個敷衍的年華 提交于 2019-12-23 20:18:07
问题 Is there a easy way to convert UUIDs from this format 5967ca5e6162317eb4a825dcdcde0aea to this format? 5967ca5e-6162-317e-b4a8-25dcdcde0aea with an MySQL Query? i need to convert over 1000 UUIDs 回答1: SET @x = '5967ca5e6162317eb4a825dcdcde0aea'; SELECT CONCAT_WS('-',MID(@x,1,8),MID(@x,9,4),MID(@x,13,4),MID(@x,17,4),MID(@x,21,1000))n; +--------------------------------------+ | n | +--------------------------------------+ | 5967ca5e-6162-317e-b4a8-25dcdcde0aea | +--------------------------------

Best (most efficient) DataType to use for UUIDs as JPA IDs

时光总嘲笑我的痴心妄想 提交于 2019-12-23 18:17:59
问题 I want to use UUIDs as IDs for my JPA Objects. I am currently just using a String to store the UUID. What would be more efficient? 回答1: How are you measuring efficiency? For example, storing the UUID (which is a text encoding of a byte[] ) as a couple of long values will allow you to compare them very quickly on a 64-bit architecture (much more quickly than String comparison, which is character-by-character). However, your coding efficiency would suffer, because you have to write a custom

How to store uuid in binary form using hibernate JPA 2

旧巷老猫 提交于 2019-12-23 12:09:49
问题 I have a question about string uuid in database in binary form through hibernate persistence (JPA2). I'm using now this code: private UUID id; @Id @Type(type="uuid-char") @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid") @Column(length = 32, unique = true, nullable = false) public final UUID getId() { return id; } This work fine, but I must store it in binary form. Don't ask me why, but I must. 回答1: The type for binary UUID is uuid-binary .

UUID data type in DynamoDB

五迷三道 提交于 2019-12-23 10:49:12
问题 A UUID is, according to the specification, 128 bits or 16 bytes. The hexadecimal representation is 36 characters including the hyphens. I'm building a new table on DynamoDB and I have to decide the Type for the Hash key which I plan on filling with UUIDs. Should I create the table with a Hash key that is a String or Binary for these UUIDs? My gut tells me byte, because its less than half the size so that saves bandwidth, space, etc. Does anybody have experience one way or the other and have a

PHP mysql_insert_id() for MySQL UUID() primary keys?

白昼怎懂夜的黑 提交于 2019-12-23 05:38:10
问题 Is there some equivalent to PHP mysql_insert_id to fetch the last inserted UUID() primary key? (I always get 0. It works for auto_inc integers though) 回答1: No, last_insert_id() only retrieves that last generated auto_increment fields. You'll have to do a select uuid() first, then do an insert using that uuid. However, note that uuids can't be guaranteed to be unique - they're simply very unlikely to collide. If you do require uniqueness, then go with an auto_increment - they'll never be re