Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/365.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.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
Java 为什么jpa选择查询被卡住?_Java_Jpa_Jpql - Fatal编程技术网

Java 为什么jpa选择查询被卡住?

Java 为什么jpa选择查询被卡住?,java,jpa,jpql,Java,Jpa,Jpql,我有一个计算数据的查询,这是一个简单的查询,查询如下: SELECT COUNT(o.id) FROM Order o WHERE o.customerId = :customerId 它不知怎么被卡住了,它不返回异常或任何东西。我想知道除了锁定一个特定的行使SELECT查询像这样卡住之外,还有什么其他的可能性?。因为就我而言,当事务完成时,一些数据库将解锁该行 仅供参考:我正在使用PostgreSQL 9.4和JDK 1.8 编辑1: 下面是我用来执行查询的一些代码 public Long

我有一个计算数据的查询,这是一个简单的查询,查询如下:

SELECT COUNT(o.id) FROM Order o WHERE o.customerId = :customerId
它不知怎么被卡住了,它不返回异常或任何东西。我想知道除了锁定一个特定的行使SELECT查询像这样卡住之外,还有什么其他的可能性?。因为就我而言,当事务完成时,一些数据库将解锁该行

仅供参考:我正在使用PostgreSQL 9.4和JDK 1.8

编辑1:

下面是我用来执行查询的一些代码

public Long findListActiveOrderByCustomerId(String customerId){
    try {
        TypedQuery<Long> query = entityManager.createNamedQuery("CustomerActiveOrderReport.findByCustomerId", Long.class);
        query.setParameter("customerId", customerId);
        Long count = query.getSingleResult();
        return count;
    } catch (NoResultException e) {
        return null;
    }
}
日志会在“开始检查活动订单客户”处停止,但它不会卡在那里,它仍然会继续,就像什么都没有发生一样。而且也没有任何例外

编辑2:

以下是一些日志:

2016-12-08 12:20:06.616 [executor-1-287] DEBUG com.daksa.tos.order.OrderResource | ### ORDER USING WEB ###
2016-12-08 12:20:06.616 [executor-1-287] DEBUG com.daksa.tos.order.OrderResource | ### START CHECK RADIUS BRANCH ###
2016-12-08 12:20:06.616 [executor-1-287] INFO  com.daksa.beemif.client.PersistentClient | sendAsync
2016-12-08 12:20:06.620 [executor-1-287] DEBUG com.daksa.tos.order.OrderResource | ### FINISH CHECK RADIUS BRANCH ###
2016-12-08 12:20:06.620 [executor-1-287] DEBUG com.daksa.tos.order.OrderResource | ### START CHECK ACTIVE ORDER CUSTOMER ###
2016-12-08 12:20:06.620 [executor-1-287] DEBUG com.daksa.tos.order.infrastructure.EntityManagerProducer | Create EntityManager
2016-12-08 12:20:12.526 [worker-3-2] DEBUG com.daksa.beemif.proto.ProtoRequestMapper | channelRead0(resource: order, method: createOrder)
2016-12-08 12:20:12.527 [executor-1-288] INFO  com.daksa.tos.order.OrderResource | ### createOrder ###
2016-12-08 12:20:12.527 [executor-1-288] INFO  com.daksa.tos.order.OrderResource | branchId 8e55ad56faa240be83b2044d79592114
2016-12-08 12:20:12.527 [executor-1-288] DEBUG com.daksa.tos.order.OrderResource | ### ORDER USING WEB ###

正如您所看到的,我的代码从“使用WEB订购”开始,一直持续到“开始检查活动订单”,但没有“完成检查活动订单客户”,它返回到“使用WEB订购”并毫无例外地继续,同时,在我的网页上显示失败。

可能仍然是working@ScaryWombat我使用本机查询在数据库中尝试了相同的查询,但返回结果的时间不到1秒。请向我们展示相关的JDBC代码,并让我们知道它在哪一行被卡住。顺便说一句,永远不要默默地吞下异常
catch(NoResultException e){return null;}
@Yusuf1494袋熊的建议正是您应该做的。这样做:用try-catch包围有问题的代码,只捕获一个普通的
异常
。使用调试器逐步检查代码,您应该会发现问题所在。
2016-12-08 12:20:06.616 [executor-1-287] DEBUG com.daksa.tos.order.OrderResource | ### ORDER USING WEB ###
2016-12-08 12:20:06.616 [executor-1-287] DEBUG com.daksa.tos.order.OrderResource | ### START CHECK RADIUS BRANCH ###
2016-12-08 12:20:06.616 [executor-1-287] INFO  com.daksa.beemif.client.PersistentClient | sendAsync
2016-12-08 12:20:06.620 [executor-1-287] DEBUG com.daksa.tos.order.OrderResource | ### FINISH CHECK RADIUS BRANCH ###
2016-12-08 12:20:06.620 [executor-1-287] DEBUG com.daksa.tos.order.OrderResource | ### START CHECK ACTIVE ORDER CUSTOMER ###
2016-12-08 12:20:06.620 [executor-1-287] DEBUG com.daksa.tos.order.infrastructure.EntityManagerProducer | Create EntityManager
2016-12-08 12:20:12.526 [worker-3-2] DEBUG com.daksa.beemif.proto.ProtoRequestMapper | channelRead0(resource: order, method: createOrder)
2016-12-08 12:20:12.527 [executor-1-288] INFO  com.daksa.tos.order.OrderResource | ### createOrder ###
2016-12-08 12:20:12.527 [executor-1-288] INFO  com.daksa.tos.order.OrderResource | branchId 8e55ad56faa240be83b2044d79592114
2016-12-08 12:20:12.527 [executor-1-288] DEBUG com.daksa.tos.order.OrderResource | ### ORDER USING WEB ###