gpt4 book ai didi

java - 特定应用种子数据群

转载 作者:行者123 更新时间:2023-11-30 11:58:43 24 4
gpt4 key购买 nike

环境:JBoss、(h2、MySQl、postgres)、JPA、Hibernate 3.3.x

@Id
@GeneratedValue(strategy = IDENTITY)
private Integer key;
  1. 目前我们的主键是使用上述注解创建的。我们希望支持大量用户(~百万用户),应该使用什么 key 。它应该是 Integer 还是 Long 还是我应该使用上述声明的未签名版本。

  2. 我们有一个 j2ee 应用程序,需要在安装时填充一些种子数据。购买时,客户会在应用程序之上创建自己的数据。我们只是想确保有足够的空间来运送、修改或添加 future 版本的数据。支持这一点的最佳机制是什么,我们已经研究过从某个 id(比如 1000)开始所有表标识符,但这要求修改主键生成以具有基于表或序列的生成器,我们有大约 100 个表。我们不确定这是否是正确的策略。

如果我们对 key 使用带符号的整数方法,那么将种子数据作为从 0 及以下开始的所有内容(即 - 五个数字)是否有意义,以便所有客户特定数据都将在 0 及以上可用(即 +ve 个数字)

最佳答案

Currently our primary keys are created using the above annotation. We expect to support a large number of users (~million users), what key should be used. Should it be Integer or Long or should I use the unsigned versions of the above declarations

来自Primitive Data Types Java 教程:

int: The int data type is a 32-bit signed two's complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally the default choice unless there is a reason (like the above) to choose something else. This data type will most likely be large enough for the numbers your program will use, but if you need a wider range of values, use long instead.

由你决定是否安全:)

(...) We just want to make sure that there is enough room to ship, modify or add data for future releases. What would be the best mechanism to support this

我会用提到的数据库对此进行测试,但对种子数据使用负 ID 似乎是更安全的解决方案(不会发生冲突)。如果它不起作用(我认为它应该起作用),那么我相信 TABLE 策略将是最便携的解决方案。

关于java - 特定应用种子数据群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3020221/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com