ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject incubator-ranger git commit: RANGER-555: Fixed x_data_hist query for Oracle DB
Date Tue, 16 Jun 2015 02:58:04 GMT
Repository: incubator-ranger
Updated Branches:
  refs/heads/master 4d60d6228 -> 6411479b8


RANGER-555: Fixed x_data_hist query for Oracle DB

Signed-off-by: sneethiraj <sneethir@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/6411479b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/6411479b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/6411479b

Branch: refs/heads/master
Commit: 6411479b8836f11df4abea9702e67c8ad29049ce
Parents: 4d60d62
Author: Velmurugan Periasamy <vel@apache.org>
Authored: Mon Jun 15 18:43:14 2015 -0400
Committer: sneethiraj <sneethir@apache.org>
Committed: Mon Jun 15 22:57:52 2015 -0400

----------------------------------------------------------------------
 .../org/apache/ranger/db/XXDataHistDao.java     | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/6411479b/security-admin/src/main/java/org/apache/ranger/db/XXDataHistDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXDataHistDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXDataHistDao.java
index b9f91d4..07db458 100644
--- a/security-admin/src/main/java/org/apache/ranger/db/XXDataHistDao.java
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXDataHistDao.java
@@ -23,6 +23,8 @@ import java.util.List;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
 
+import org.apache.ranger.biz.RangerBizUtil;
+import org.apache.ranger.common.AppConstants;
 import org.apache.ranger.common.db.BaseDao;
 import org.apache.ranger.entity.XXDataHist;
 
@@ -52,8 +54,22 @@ public class XXDataHistDao extends BaseDao<XXDataHist> {
 			return null;
 		}
 		try {
-			String queryStr = "select obj.* from x_data_hist obj where obj.obj_class_type = "+classType
-					+ " and obj.obj_id = "+objId + " and obj.create_time <= '" + eventTime + "' ORDER
BY obj.id DESC";
+
+			int dbFlavor = RangerBizUtil.getDBFlavor();
+
+			String queryStr = "";
+
+			if (dbFlavor == AppConstants.DB_FLAVOR_ORACLE) {
+				queryStr = "select obj.* from x_data_hist obj where obj.obj_class_type = " + classType
+						+ " and obj.obj_id = " + objId
+						+ " and to_date(obj.create_time, 'YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"') <= to_date('"
+ eventTime
+						+ "', 'YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"') ORDER BY obj.id DESC";
+			} else {
+				queryStr = "select obj.* from x_data_hist obj where obj.obj_class_type = " + classType
+						+ " and obj.obj_id = " + objId + " and obj.create_time <= '" + eventTime
+						+ "' ORDER BY obj.id DESC";
+			}
+
 			Query jpaQuery = getEntityManager().createNativeQuery(queryStr, tClass).setMaxResults(1);
 			
 			return (XXDataHist) jpaQuery.getSingleResult();


Mime
View raw message