title: Why does jpa select query stuck?
body: <p>I have query which to count data, and it's a simple one, here's the query:</p>
  
  <pre><code>SELECT COUNT(o.id) FROM Order o WHERE o.customerId = :customerId
  </code></pre>
  
  <p>and it get stuck somehow, it doesn't return exception or anything. I want to know what other possibilities beside locking a specific row which makes SELECT query to stuck like this?. Because as far as I'm concerned some of databases are gonna unlock the row when transaction is completed.</p>
  
  <p>FYI:  I am using PostgreSQL 9.4, and JDK 1.8.</p>
  
  <p>EDIT 1:</p>
  
  <p>Here's some of the codes which I use to execute the query</p>
  
  <pre><code>public Long findListActiveOrderByCustomerId(String customerId){
      try {
          TypedQuery&lt;Long&gt; query = entityManager.createNamedQuery("CustomerActiveOrderReport.findByCustomerId", Long.class);
          query.setParameter("customerId", customerId);
          Long count = query.getSingleResult();
          return count;
      } catch (NoResultException e) {
          return null;
      }
  }
  </code></pre>
  
  <p>And it's called here :</p>
  
  <pre><code>LOG.debug("### START CHECK ACTIVE ORDER CUSTOMER ###");
      Long orderList = customerOrderRepository.findListActiveOrderByCustomerId(customerId);
          if (orderList &gt; 0) {
              LOG.error("orderList &gt; 0");
              throw new InvalidOrderException("Customer already has active order");
          }
  LOG.debug("### FINISH CHECK ACTIVE ORDER CUSTOMER ###");
  </code></pre>
  
  <p>the log stop at "START CHECK ACTIVE ORDER CUSTOMER", but it doesn't stuck right there, it still continue like nothing happens at all. And it doesn't show any exception.</p>
  
  <p>EDIT 2:</p>
  
  <p>Here's a couple of logs:</p>
  
  <pre><code>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 ###
  </code></pre>
  
  <p>as you can see my codes start at "ORDER USING WEB" and it goes on till "START CHECK ACTIVE ORDER", but there's no "FINISH CHECK ACTIVE ORDER CUSTOMER" it came back to "ORDER USING WEB" and goes on without exception, meanwhile on my web page page shows Failed.</p>