ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [24/34] ambari git commit: AMBARI-20847 - Remove Refresh Query Hint From Upgrade DAO (jonathanhurley)
Date Wed, 26 Apr 2017 18:01:30 GMT
AMBARI-20847 - Remove Refresh Query Hint From Upgrade DAO (jonathanhurley)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/09ca4857
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/09ca4857
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/09ca4857

Branch: refs/heads/branch-feature-AMBARI-12556
Commit: 09ca4857986eb734b93b5862620a85c8bff7b691
Parents: 35d7220
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Tue Apr 25 12:08:40 2017 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Tue Apr 25 17:31:00 2017 -0400

----------------------------------------------------------------------
 .../ambari/server/orm/dao/UpgradeDAO.java       | 30 ++------------------
 .../server/orm/entities/UpgradeEntity.java      |  2 ++
 2 files changed, 5 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/09ca4857/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UpgradeDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UpgradeDAO.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UpgradeDAO.java
index 4666edf..716f5b5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UpgradeDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UpgradeDAO.java
@@ -27,8 +27,6 @@ import org.apache.ambari.server.orm.entities.UpgradeEntity;
 import org.apache.ambari.server.orm.entities.UpgradeGroupEntity;
 import org.apache.ambari.server.orm.entities.UpgradeItemEntity;
 import org.apache.ambari.server.state.stack.upgrade.Direction;
-import org.eclipse.persistence.config.HintValues;
-import org.eclipse.persistence.config.QueryHints;
 
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -90,10 +88,10 @@ public class UpgradeDAO {
 
   @RequiresSession
   public UpgradeEntity findUpgradeByRequestId(Long requestId) {
-    TypedQuery<UpgradeEntity> query = entityManagerProvider.get().createQuery(
-        "SELECT p FROM UpgradeEntity p WHERE p.requestId = :requestId", UpgradeEntity.class);
+    TypedQuery<UpgradeEntity> query = entityManagerProvider.get().createNamedQuery(
+        "UpgradeEntity.findUpgradeByRequestId", UpgradeEntity.class);
+
     query.setParameter("requestId", requestId);
-    query.setHint(QueryHints.REFRESH, HintValues.TRUE);
 
     return daoUtils.selectSingle(query);
   }
@@ -131,26 +129,10 @@ public class UpgradeDAO {
     TypedQuery<UpgradeGroupEntity> query = entityManagerProvider.get().createQuery(
         "SELECT p FROM UpgradeGroupEntity p WHERE p.upgradeGroupId = :groupId", UpgradeGroupEntity.class);
     query.setParameter("groupId", groupId);
-    query.setHint(QueryHints.REFRESH, HintValues.TRUE);
-
-    return daoUtils.selectSingle(query);
-  }
-
-  /**
-   * @param itemId the item id
-   * @return the upgrade item entity, or {@code null} if not found
-   */
-  @RequiresSession
-  public UpgradeItemEntity findUpgradeItem(long itemId) {
-    TypedQuery<UpgradeItemEntity> query = entityManagerProvider.get().createQuery(
-        "SELECT p FROM UpgradeItemEntity p WHERE p.upgradeItemId = :itemId", UpgradeItemEntity.class);
-    query.setParameter("itemId", Long.valueOf(itemId));
-    query.setHint(QueryHints.REFRESH, HintValues.TRUE);
 
     return daoUtils.selectSingle(query);
   }
 
-
   /**
    * @param requestId the request id
    * @param stageId the stage id
@@ -164,8 +146,6 @@ public class UpgradeDAO {
     query.setParameter("requestId", requestId);
     query.setParameter("stageId", stageId);
 
-    query.setHint(QueryHints.REFRESH, HintValues.TRUE);
-
     return daoUtils.selectSingle(query);
   }
 
@@ -184,8 +164,6 @@ public class UpgradeDAO {
     query.setParameter("clusterId", clusterId);
     query.setParameter("direction", direction);
 
-    query.setHint(QueryHints.REFRESH, HintValues.TRUE);
-
     return daoUtils.selectSingle(query);
   }
 
@@ -200,8 +178,6 @@ public class UpgradeDAO {
     query.setMaxResults(1);
     query.setParameter("clusterId", clusterId);
 
-    query.setHint(QueryHints.REFRESH, HintValues.TRUE);
-
     return daoUtils.selectSingle(query);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/09ca4857/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
index de1454b..e5e2de3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradeEntity.java
@@ -59,6 +59,8 @@ import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
       query = "SELECT u FROM UpgradeEntity u WHERE u.clusterId = :clusterId"),
   @NamedQuery(name = "UpgradeEntity.findUpgrade",
       query = "SELECT u FROM UpgradeEntity u WHERE u.upgradeId = :upgradeId"),
+  @NamedQuery(name = "UpgradeEntity.findUpgradeByRequestId",
+      query = "SELECT u FROM UpgradeEntity u WHERE u.requestId = :requestId"),  
   @NamedQuery(name = "UpgradeEntity.findLatestForClusterInDirection",
       query = "SELECT u FROM UpgradeEntity u JOIN RequestEntity r ON u.requestId = r.requestId
WHERE u.clusterId = :clusterId AND u.direction = :direction ORDER BY r.startTime DESC, u.upgradeId
DESC"),
   @NamedQuery(name = "UpgradeEntity.findLatestForCluster",


Mime
View raw message