Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
哪个MySQL数据类型将存储这个Java BigInteger?_Java_Mysql_Hibernate_Biginteger - Fatal编程技术网

哪个MySQL数据类型将存储这个Java BigInteger?

哪个MySQL数据类型将存储这个Java BigInteger?,java,mysql,hibernate,biginteger,Java,Mysql,Hibernate,Biginteger,我正在使用Java6、Hibernate4.1.0.Final和Spring3.1.1.RELEASE。我有一个字符串(最多32个字符),我希望将其转换为数字,然后再转换回字符串。我想知道我应该使用什么MySQL(V5.5)数据类型来存储数字(我认为是一个大整数),我还想知道是否有更好的方法来进行转换。现在,我正在做 // Convert to integer final BigInteger bigInt = new BigInteger(myString.getBytes()); // C

我正在使用Java6、Hibernate4.1.0.Final和Spring3.1.1.RELEASE。我有一个字符串(最多32个字符),我希望将其转换为数字,然后再转换回字符串。我想知道我应该使用什么MySQL(V5.5)数据类型来存储数字(我认为是一个大整数),我还想知道是否有更好的方法来进行转换。现在,我正在做

// Convert to integer
final BigInteger bigInt = new BigInteger(myString.getBytes());

// Convert back to a string
final String oldString = new String(bigInt.toByteArray());
相关字段上的Hibernate映射是

@Column(name = "ORDER_ID")
private BigInteger orderId;

感谢您的帮助,-

查看数字数据类型。我用它来存储非常大的十进制数,最长可达39位

数据库字段的类型为“NUMERIC(39)”

使用的hibernate映射是:

<property name="foo" type="big_integer" column="ORDER_ID" length="39"/>

你能指定字符串的格式吗?它是一个数字字符串,例如“12345”,还是一个字节整数序列?该字符串可能包含数字,但不一定包含数字。它将是一个GUID——因此是一个32个字符的序列,其中每个字符都是从“a”到“F”的字母的数字。尝试了这个方法,但没有成功。获取错误“org.hibernate.exception.DataException:数据截断:第1行'ORDER_ID'列的值超出范围”用hibernate和mysql详细信息更新了我的答案。您尝试了哪些映射和列类型?我发现NUMERIC(50)解决了一些问题(从另一方面来说,我仍然会遇到一些错误)。为后代添加了Hibernate映射。
BigInteger bigInt = new BigInteger(myString, 16);