为什么UUID的格式为"8-4-4-4-12"(数字)?我已经看了看原因,但找不到要求它的决定.
格式为十六进制字符串的UUID示例:58D5E212-165B-4CA0-909B-C86B9CEE0111
我一直在尝试使用UUID作为数据库密钥.我想尽可能占用最少的字节数,同时仍然保持UUID表示可读.
我认为我已经使用base64将它降低到22个字节,并删除了一些似乎没有必要为我的目的存储的尾随"==".这种方法有什么缺陷吗?
基本上我的测试代码会进行一系列转换,以将UUID降低到22字节的字符串,然后将其转换回UUID.
import java.io.IOException;
import java.util.UUID;
public class UUIDTest {
public static void main(String[] args){
UUID uuid = UUID.randomUUID();
System.out.println("UUID String: " + uuid.toString());
System.out.println("Number of Bytes: " + uuid.toString().getBytes().length);
System.out.println();
byte[] uuidArr = asByteArray(uuid);
System.out.print("UUID Byte Array: ");
for(byte b: uuidArr){
System.out.print(b +" ");
}
System.out.println();
System.out.println("Number of Bytes: " + uuidArr.length);
System.out.println();
try {
// Convert a byte array to base64 string
String s = new sun.misc.BASE64Encoder().encode(uuidArr);
System.out.println("UUID Base64 String: " +s);
System.out.println("Number of Bytes: " + …Run Code Online (Sandbox Code Playgroud) 我正在使用我的uuid如下:
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid")
@Column(name = "uuid", unique = true)
private String uuid;
Run Code Online (Sandbox Code Playgroud)
但我得到了一个聪明的Hibernate警告:
使用org.hibernate.id.UUIDHexGenerator,它不生成符合IETF RFC 4122的UUID值; 考虑使用org.hibernate.id.UUIDGenerator
所以我想切换到org.hibernate.id.UUIDGenerator,现在我的问题是如何告诉Hibernate的生成器.我看到有人把它用作"hibernate-uuid" - 所以这就是我尝试过的,但结果是否定的:
@Id
@GeneratedValue(generator = "hibernate-uuid")
@GenericGenerator(name = "hibernate-uuid", strategy = "hibernate-uuid")
@Column(name = "uuid", unique = true)
private String uuid;
Run Code Online (Sandbox Code Playgroud) 我正在开发一个iOS应用程序,它调用web服务进行登录,然后我将登录凭据与供应商标识符(identifierForVendor)一起发送到Web服务器,以便为这些凭证唯一地标识设备.因此用户只能拥有一个设备和一个凭证.
我有了identifierForVendor
NSString *uuid = [[UIDevice currentDevice] identifierForVendor].UUIDString
Run Code Online (Sandbox Code Playgroud)
然后该标识符将存储在Web服务器的数据库中以及设备数据库中.当用户打开应用程序并尝试从Web服务器下载数据时,用户设备上的本地identifierForVendor将与存储在Web服务器上的标识符进行比较.
用户卸载应用程序并重新安装时出现问题,我发现identifierForVendor已更改.因此用户无法继续前进.
我阅读了苹果文档UIDevice Documentation
如前所述,如果来自同一供应商的所有应用程序都从设备卸载,则在从该供应商新安装任何应用程序时将采用新的identifierForVendor.
那么在我的案例中如何处理这个问题呢?
如果使用PostgreSQL(Postgres),有没有办法在SQLAlchemy中将列(主键)定义为UUID?
我正在使用这个电话:
Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID);
Run Code Online (Sandbox Code Playgroud)
获取设备的UID.我想我从多个设备获得相同的ID.这有可能吗?
相关ID是:9774d56d682e549c,显然有几个设备返回此ID的问题http://code.google.com/p/android/issues/list?cursor=10603&updated=10603&ts=1295993403
我有这个代码:
String uuid = UUID.randomUUID().toString().replace("-", "");
Run Code Online (Sandbox Code Playgroud)
在生成的UUID中删除" - "有多安全?删除它会破坏它全局唯一的目的,并使生成的UUID容易发生冲突吗?
我需要在变量中存储128位长的UUID.C++中是否有128位数据类型?我不需要算术运算,我只是想快速存储和读取值.
C++ 11的一个新功能也可以.
我希望在Windows,MacOS以及Linux(如果可能的话)上获得一台带有Java的计算机的唯一ID.它可能是磁盘UUID,主板S/N ......
Runtime.getRuntime().exec 可以使用(它不是applet).
想法?
uuid ×10
java ×5
android ×1
annotations ×1
base64 ×1
bytearray ×1
c++ ×1
format ×1
guid ×1
hibernate ×1
identifier ×1
ios ×1
orm ×1
performance ×1
postgresql ×1
python ×1
sql ×1
sqlalchemy ×1
types ×1