小编Gil*_*ili的帖子

MyBatis:如何在Postgres下返回插入对象的ID?

我有一个postgres表,其中ID定义为bigserial。如何使用@Insert和获取插入实体的ID?我期望mapper方法返回ID或填充实体对象内的ID字段。有任何想法吗?

annotations ibatis mybatis

5
推荐指数
1
解决办法
9244
查看次数

延迟加载库?

是否有一个图书馆专门处理延迟加载类字段而没有完全成熟的ORM的所有花俏?或者,哪个ORM(具有自由许可证)提供了我可以重用的最佳延迟加载机制?

java orm lazy-loading

5
推荐指数
1
解决办法
580
查看次数

每个连接缓存PreparedStatement还是让连接池处理它?

哪种缓存策略更快,速度是多少?

1)PreparedStatement池(通过连接池).应用程序没有缓存.

for (int i=0; i<1000; i++) {
    PreparedStatement preparedStatement = connection.prepareStatement(sql);
    preparedStatement.setObject(1, someValue);
    preparedStatement.executeQuery();
    preparedStatement.close();
}
Run Code Online (Sandbox Code Playgroud)

2)应用程序级缓存.没有PreparedStatement汇集.

PreparedStatement preparedStatement = connection.prepareStatement(sql);
for (int i=0; i<1000; i++) {
    preparedStatement.clearParameters();
    preparedStatement.setObject(1, someValue);
    preparedStatement.executeQuery();
}
preparedStatement.close();
Run Code Online (Sandbox Code Playgroud)

这个问题类似于多次重用PreparedStatement,除了我期待具体的基准测试结果以及考虑PreparedStatement池.

http://drupal.org/node/550124#comment-2224630似乎表明应用程序级缓存比PreparedStatement池更有效,但差异可以忽略不计.我想在做出决定之前看到更多基准.

connection-pooling jdbc prepared-statement

5
推荐指数
1
解决办法
2232
查看次数

数据库:插入新行还是更新现有行?

面向对象的设计鼓励使用不可变对象来提高线程安全性和性能.我想知道这是否会延续到关系数据库.

我最好更新现有的行,还是插入新的行作为覆盖?

  • 用例
    • 每个员工只与一家公司相关联
    • 员工随着时间的推移改变他们的公司.
    • 员工姓名应该是唯一的.
  • 架构
    • 员工[姓名,公司]

选项1:每次员工更换公司时,请插入新的员工[姓名,公司]行.指示应用程序跳过较旧的行(随着时间的推移在后台线程中进行修剪). 选项2:每次员工更换公司时,都要更新现有行.

选项1让我想起了不可变对象,因为它是线程安全的(不需要锁).另一方面,每次员工更换公司时,我都必须克隆所有相关对象并将其指向新记录.此外,还不清楚如何防止重复的员工被错误地创建.

选项2可以很容易地防止重复的员工,但是在READ_COMMITTED事务隔离中返回可能不一致的关联的缺点.

database-design

5
推荐指数
1
解决办法
3200
查看次数

如何将"jar:file"URI转换为Jar文件的路径?

如何从去jar:file:/C:/Program%20Files/test.jar!/foo/bar到一个File指向C:/Program Files/test.jar

java uri

5
推荐指数
2
解决办法
1万
查看次数

为什么Android要求包名至少有两个标识符?

在创建新的Android应用程序时,Eclipse抱怨Package name must have at least two identifiers并且Netbeans抱怨Package name must have at least two parts (Android Bug).

我理解如何解决这个问题.我的问题是:这种限制来自何处?我没有在Android文档或问题跟踪器中找到它.

android

5
推荐指数
1
解决办法
8609
查看次数

浏览器返回带有空responseText的HTTP 200

我使用以下代码重试返回HTTP 502,503或504的操作:

/**
 * @function RetryDelayFunction
 * Returns the amount of time to wait after a failure.
 *
 * @param {Number} retries the number of times the operation has been retried
 * @return {Number} the number of milliseconds to wait before retrying the operation
 */

/**
 * @typedef {Object} RetryAjaxOptions
 *
 * @property {Number} retries the number of times to retry a failed operation
 * @param {RetryDelayFunction} delayFunction maps a failure count to a delay in milliseconds
 * @param {Array} …
Run Code Online (Sandbox Code Playgroud)

ajax jquery

5
推荐指数
1
解决办法
366
查看次数

How to rename resources in an idempotent manner?

I implemented an API that renames a company as follows:

PUT /companies/A
{
  "name": "B"
}
Run Code Online (Sandbox Code Playgroud)

will return HTTP 301 with the Location header pointing at the company's new URI: /companies/B.

How can I make this operation idempotent with and without If-Match headers?

  1. Without If-Match header: if a user tries to rename a non-existent company, I'd expect the server to return HTTP 404 but I can't do so because then legitimate rename operations wouldn't be idempotent (they'd return 301 …

rest http-put idempotent

5
推荐指数
2
解决办法
1828
查看次数

Jersey 2:如何将参数从 web.xml 传递到应用程序?

我的 Web 容器知道我的应用程序是在调试模式还是发布模式下运行。我想将此信息传递给我的 ResourceConfig/Application 类,但不清楚如何读取此信息。

是否可以通过 servlet/filter 参数传递信息?如果是这样,如何?

jax-rs jersey jersey-2.0

5
推荐指数
1
解决办法
4679
查看次数

如何结合使用正则表达式和代码来验证 IPv6 地址?

我想使用强调可读性的算法来验证 IPv6 地址。理想的解决方案将极其简单的正则表达式与源代码结合起来。

https://blogs.msdn.microsoft.com/oldnewthing/20060522-08/?p=31113为例:

function isDottedIPv4(s)
{
  var match = s.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
  return match != null &&
         match[1] <= 255 && match[2] <= 255 &&
         match[3] <= 255 && match[4] <= 255;
}
Run Code Online (Sandbox Code Playgroud)

请注意 Raymond 如何将复杂性从正则表达式转移到代码中。我想要一个对 IPv6 具有相同功能的解决方案。

javascript regex

5
推荐指数
1
解决办法
2850
查看次数