You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ve...@apache.org on 2015/04/07 20:32:28 UTC

incubator-ranger git commit: RANGER-300 : Preserve ids during migration

Repository: incubator-ranger
Updated Branches:
  refs/heads/master 7ecfa0536 -> 53709aad8


RANGER-300 : Preserve ids during migration

Signed-off-by: Velmurugan Periasamy <ve...@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/53709aad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/53709aad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/53709aad

Branch: refs/heads/master
Commit: 53709aad8bca8b326c81766738a4ffbaeff66fb8
Parents: 7ecfa05
Author: Gautam Borad <gb...@gmail.com>
Authored: Tue Apr 7 20:26:53 2015 +0530
Committer: Velmurugan Periasamy <ve...@apache.org>
Committed: Tue Apr 7 14:28:32 2015 -0400

----------------------------------------------------------------------
 .../org/apache/ranger/biz/ServiceDBStore.java   |  26 +-
 .../org/apache/ranger/common/AppConstants.java  |   8 +
 .../apache/ranger/db/RangerDaoManagerBase.java  |  20 ++
 .../java/org/apache/ranger/db/XXPolicyDao.java  |   8 +
 .../ranger/db/XXPolicyWithAssignedIdDao.java    |  12 +
 .../java/org/apache/ranger/db/XXServiceDao.java |   8 +
 .../ranger/db/XXServiceWithAssignedIdDao.java   |  12 +
 .../java/org/apache/ranger/entity/XXPolicy.java | 291 +---------------
 .../org/apache/ranger/entity/XXPolicyBase.java  | 287 ++++++++++++++++
 .../ranger/entity/XXPolicyWithAssignedId.java   |  57 +++
 .../org/apache/ranger/entity/XXService.java     | 343 +------------------
 .../org/apache/ranger/entity/XXServiceBase.java | 333 ++++++++++++++++++
 .../ranger/entity/XXServiceWithAssignedId.java  |  59 ++++
 .../ranger/patch/PatchMigration_J10002.java     |  49 +++
 .../ranger/service/RangerPolicyService.java     | 147 +-------
 .../ranger/service/RangerPolicyServiceBase.java | 165 ++++++++-
 .../RangerPolicyWithAssignedIdService.java      |  61 ++++
 .../ranger/service/RangerServiceService.java    |  29 +-
 .../service/RangerServiceServiceBase.java       |  28 +-
 .../RangerServiceWithAssignedIdService.java     |  60 ++++
 .../resources/META-INF/jpa_named_queries.xml    |   8 +
 21 files changed, 1222 insertions(+), 789 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
index 6333b09..2506d66 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
@@ -98,11 +98,13 @@ import org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef;
 import org.apache.ranger.plugin.store.EmbeddedServiceDefsUtil;
 import org.apache.ranger.plugin.store.AbstractServiceStore;
 import org.apache.ranger.plugin.util.ServicePolicies;
+import org.apache.ranger.service.RangerPolicyWithAssignedIdService;
 import org.apache.ranger.service.RangerAuditFields;
 import org.apache.ranger.service.RangerDataHistService;
 import org.apache.ranger.service.RangerPolicyService;
 import org.apache.ranger.service.RangerServiceDefService;
 import org.apache.ranger.service.RangerServiceService;
+import org.apache.ranger.service.RangerServiceWithAssignedIdService;
 import org.apache.ranger.service.XUserService;
 import org.apache.ranger.view.RangerPolicyList;
 import org.apache.ranger.view.RangerServiceDefList;
@@ -159,6 +161,12 @@ public class ServiceDBStore extends AbstractServiceStore {
     
     @Autowired
     RangerBizUtil bizUtil;
+    
+    @Autowired
+    RangerPolicyWithAssignedIdService assignedIdPolicyService;
+    
+    @Autowired
+    RangerServiceWithAssignedIdService svcServiceWithAssignedId;
 
 	private static volatile boolean legacyServiceDefsInitDone = false;
 	private Boolean populateExistingBaseFields = false;
@@ -444,9 +452,9 @@ public class ServiceDBStore extends AbstractServiceStore {
 			service.setVersion(new Long(1));
 			
 			if(populateExistingBaseFields) {
-				svcService.setPopulateExistingBaseFields(true);
-				service = svcService.create(service);
-				svcService.setPopulateExistingBaseFields(false);
+				svcServiceWithAssignedId.setPopulateExistingBaseFields(true);
+				service = svcServiceWithAssignedId.create(service);
+				svcServiceWithAssignedId.setPopulateExistingBaseFields(false);
 				createDefaultPolicy = false;
 			} else {
 				service = svcService.create(service);
@@ -548,9 +556,9 @@ public class ServiceDBStore extends AbstractServiceStore {
 		service.setVersion(version);
 
 		if(populateExistingBaseFields) {
-			svcService.setPopulateExistingBaseFields(true);
-			service = svcService.update(service);
-			svcService.setPopulateExistingBaseFields(false);
+			svcServiceWithAssignedId.setPopulateExistingBaseFields(true);
+			service = svcServiceWithAssignedId.update(service);
+			svcServiceWithAssignedId.setPopulateExistingBaseFields(false);
 		} else {
 			service = svcService.update(service);
 		}
@@ -716,9 +724,9 @@ public class ServiceDBStore extends AbstractServiceStore {
 		policy.setVersion(new Long(1));
 
 		if(populateExistingBaseFields) {
-			policyService.setPopulateExistingBaseFields(true);
-			policy = policyService.create(policy);
-			policyService.setPopulateExistingBaseFields(false);
+			assignedIdPolicyService.setPopulateExistingBaseFields(true);
+			policy = assignedIdPolicyService.create(policy);
+			assignedIdPolicyService.setPopulateExistingBaseFields(false);
 		} else {
 			policy = policyService.create(policy);
 		}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java b/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
index a5ecff7..f9eb61b 100644
--- a/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
+++ b/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
@@ -505,6 +505,14 @@ public class AppConstants extends RangerCommonEnums {
 	 * CLASS_TYPE_XA_SERVICE_DEF is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_SERVICE_DEF".
 	 */
 	public static final int CLASS_TYPE_XA_SERVICE_DEF = 1033;
+	/**
+	 * CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID is an element of enum ClassTypes. Its value is "CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID".
+	 */
+	public static final int CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID = 1037;
+	/**
+	 * CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID is an element of enum ClassTypes. Its value is "CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID".
+	 */
+	public static final int CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID = 1038;
 
 	/**
 	 * CLASS_TYPE_RANGER_MODULE_DEF is an element of enum ClassTypes. Its value is "CLASS_TYPE_RANGER_MODULE_DEF".

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/db/RangerDaoManagerBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/RangerDaoManagerBase.java b/security-admin/src/main/java/org/apache/ranger/db/RangerDaoManagerBase.java
index 2dd0797..06bb6db 100644
--- a/security-admin/src/main/java/org/apache/ranger/db/RangerDaoManagerBase.java
+++ b/security-admin/src/main/java/org/apache/ranger/db/RangerDaoManagerBase.java
@@ -143,6 +143,12 @@ public abstract class RangerDaoManagerBase {
 		if (classType == AppConstants.CLASS_TYPE_XA_DATA_HIST) {
 			return getXXDataHist();
 		}
+		if (classType == AppConstants.CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID) {
+			return getXXPolicyWithAssignedId();
+		}
+		if (classType == AppConstants.CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID) {
+			return getXXServiceWithAssignedId();
+		}
 		if (classType == AppConstants.CLASS_TYPE_RANGER_MODULE_DEF) {
 			return getXXModuleDef();
 		}
@@ -263,6 +269,12 @@ public abstract class RangerDaoManagerBase {
 		if (className.equals("XXDataHist")) {
 			return getXXDataHist();
 		}
+		if (className.equals("XXPolicyWithAssignedId")) {
+			return getXXPolicyWithAssignedId();
+		}
+		if (className.equals("XXServiceWithAssignedId")) {
+			return getXXServiceWithAssignedId();
+		}
 		if (className.equals("XXModuleDef")) {
 			return getXXModuleDef();
 		}
@@ -423,6 +435,14 @@ public abstract class RangerDaoManagerBase {
 	public XXDataHistDao getXXDataHist() {
 		return new XXDataHistDao(this);
 	}
+	
+	public XXPolicyWithAssignedIdDao getXXPolicyWithAssignedId() {
+		return new XXPolicyWithAssignedIdDao(this);
+	}
+	
+	public XXServiceWithAssignedIdDao getXXServiceWithAssignedId() {
+		return new XXServiceWithAssignedIdDao(this);
+	}
 
 	public XXModuleDefDao getXXModuleDef(){
 		return new XXModuleDefDao(this);

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/db/XXPolicyDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXPolicyDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXPolicyDao.java
index 89eff56..c132f3c 100644
--- a/security-admin/src/main/java/org/apache/ranger/db/XXPolicyDao.java
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXPolicyDao.java
@@ -47,4 +47,12 @@ public class XXPolicyDao extends BaseDao<XXPolicy> {
 		}
 	}
 
+	public Long getMaxIdOfXXPolicy() {
+		try {
+			return (Long) getEntityManager().createNamedQuery("XXPolicy.getMaxIdOfXXPolicy").getSingleResult();
+		} catch (NoResultException e) {
+			return null;
+		}
+	}
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/db/XXPolicyWithAssignedIdDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXPolicyWithAssignedIdDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXPolicyWithAssignedIdDao.java
new file mode 100644
index 0000000..434847b
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXPolicyWithAssignedIdDao.java
@@ -0,0 +1,12 @@
+package org.apache.ranger.db;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXPolicyWithAssignedId;
+
+public class XXPolicyWithAssignedIdDao extends BaseDao<XXPolicyWithAssignedId> {
+
+	public XXPolicyWithAssignedIdDao(RangerDaoManagerBase daoManager) {
+		super(daoManager);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/db/XXServiceDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXServiceDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXServiceDao.java
index 50d1e94..2ea8b29 100644
--- a/security-admin/src/main/java/org/apache/ranger/db/XXServiceDao.java
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXServiceDao.java
@@ -29,4 +29,12 @@ public class XXServiceDao extends BaseDao<XXService> {
 		}
 	}
 
+	public Long getMaxIdOfXXService() {
+		try {
+			return (Long) getEntityManager().createNamedQuery("XXService.getMaxIdOfXXService").getSingleResult();
+		} catch (NoResultException e) {
+			return null;
+		}
+	}
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/db/XXServiceWithAssignedIdDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXServiceWithAssignedIdDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXServiceWithAssignedIdDao.java
new file mode 100644
index 0000000..246c162
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXServiceWithAssignedIdDao.java
@@ -0,0 +1,12 @@
+package org.apache.ranger.db;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXServiceWithAssignedId;
+
+public class XXServiceWithAssignedIdDao extends BaseDao<XXServiceWithAssignedId> {
+
+	public XXServiceWithAssignedIdDao(RangerDaoManagerBase daoManager) {
+		super(daoManager);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/entity/XXPolicy.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicy.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicy.java
index abbfeb4..d24695a 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicy.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicy.java
@@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 @Cacheable
 @XmlRootElement
 @Table(name = "x_policy")
-public class XXPolicy extends XXDBBase implements java.io.Serializable {
+public class XXPolicy extends XXPolicyBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 	/**
 	 * id of the XXPolicy
@@ -39,307 +39,36 @@ public class XXPolicy extends XXDBBase implements java.io.Serializable {
 	@Column(name = "id")
 	protected Long id;
 
-	/**
-	 * Global Id for the object
-	 * <ul>
-	 * <li>The maximum length for this attribute is <b>512</b>.
-	 * </ul>
-	 *
-	 */
-	@Column(name = "guid", unique = true, nullable = false, length = 512)
-	protected String guid;
-	
-	/**
-	 * version of the XXPolicy
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "version")
-	protected Long version;
-
-	/**
-	 * service of the XXPolicy
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "service")
-	protected Long service;
-
-	/**
-	 * name of the XXPolicy
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "name")
-	protected String name;
-
-	/**
-	 * description of the XXPolicy
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "description")
-	protected String description;
-
-	/**
-	 * isEnabled of the XXPolicy
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "is_enabled")
-	protected boolean isEnabled;
-
-	/**
-	 * isAuditEnabled of the XXPolicy
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "is_audit_enabled")
-	protected boolean isAuditEnabled;
-
-	/**
-	 * This method sets the value to the member attribute <b> id</b> . You
-	 * cannot set null to the attribute.
-	 * 
-	 * @param id
-	 *            Value to set member attribute <b> id</b>
-	 */
+	@Override
 	public void setId(Long id) {
 		this.id = id;
 	}
 
-	/**
-	 * Returns the value for the member attribute <b>id</b>
-	 * 
-	 * @return Date - value of member attribute <b>id</b> .
-	 */
+	@Override
 	public Long getId() {
-		return this.id;
-	}
-
-	/**
-	 * @return the gUID
-	 */
-	public String getGuid() {
-		return guid;
-	}
-
-	/**
-	 * @param gUID
-	 *            the gUID to set
-	 */
-	public void setGuid(String gUID) {
-		guid = gUID;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> version</b> . You
-	 * cannot set null to the attribute.
-	 * 
-	 * @param version
-	 *            Value to set member attribute <b> version</b>
-	 */
-	public void setVersion(Long version) {
-		this.version = version;
+		return id;
 	}
 
-	/**
-	 * Returns the value for the member attribute <b>version</b>
-	 * 
-	 * @return Date - value of member attribute <b>version</b> .
-	 */
-	public Long getVersion() {
-		return this.version;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> service</b> . You
-	 * cannot set null to the attribute.
-	 * 
-	 * @param service
-	 *            Value to set member attribute <b> service</b>
-	 */
-	public void setService(Long service) {
-		this.service = service;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>service</b>
-	 * 
-	 * @return Date - value of member attribute <b>service</b> .
-	 */
-	public Long getService() {
-		return this.service;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> name</b> . You
-	 * cannot set null to the attribute.
-	 * 
-	 * @param name
-	 *            Value to set member attribute <b> name</b>
-	 */
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>name</b>
-	 * 
-	 * @return Date - value of member attribute <b>name</b> .
-	 */
-	public String getName() {
-		return this.name;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> description</b> .
-	 * You cannot set null to the attribute.
-	 * 
-	 * @param description
-	 *            Value to set member attribute <b> description</b>
-	 */
-	public void setDescription(String description) {
-		this.description = description;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>description</b>
-	 * 
-	 * @return Date - value of member attribute <b>description</b> .
-	 */
-	public String getDescription() {
-		return this.description;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> isEnabled</b> .
-	 * You cannot set null to the attribute.
-	 * 
-	 * @param isEnabled
-	 *            Value to set member attribute <b> isEnabled</b>
-	 */
-	public void setIsEnabled(boolean isEnabled) {
-		this.isEnabled = isEnabled;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>isEnabled</b>
-	 * 
-	 * @return Date - value of member attribute <b>isEnabled</b> .
-	 */
-	public boolean getIsEnabled() {
-		return this.isEnabled;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> isAuditEnabled</b>
-	 * . You cannot set null to the attribute.
-	 * 
-	 * @param isAuditEnabled
-	 *            Value to set member attribute <b> isAuditEnabled</b>
-	 */
-	public void setIsAuditEnabled(boolean isAuditEnabled) {
-		this.isAuditEnabled = isAuditEnabled;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>isAuditEnabled</b>
-	 * 
-	 * @return Date - value of member attribute <b>isAuditEnabled</b> .
-	 */
-	public boolean getIsAuditEnabled() {
-		return this.isAuditEnabled;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.lang.Object#equals(java.lang.Object)
-	 */
 	@Override
 	public boolean equals(Object obj) {
-		if(!super.equals(obj)) {
-			return false;
-		}
-		if (this == obj) {
+		if (this == obj)
 			return true;
-		}
-		if (!super.equals(obj)) {
+		if (!super.equals(obj))
 			return false;
-		}
-		if (getClass() != obj.getClass()) {
+		if (getClass() != obj.getClass())
 			return false;
-		}
 		XXPolicy other = (XXPolicy) obj;
-		if (guid == null) {
-			if (other.guid != null) {
-				return false;
-			}
-		} else if (!guid.equals(other.guid)) {
-			return false;
-		}
-		if (description == null) {
-			if (other.description != null) {
-				return false;
-			}
-		} else if (!description.equals(other.description)) {
-			return false;
-		}
 		if (id == null) {
-			if (other.id != null) {
-				return false;
-			}
-		} else if (!id.equals(other.id)) {
-			return false;
-		}
-		if (isAuditEnabled != other.isAuditEnabled) {
-			return false;
-		}
-		if (isEnabled != other.isEnabled) {
-			return false;
-		}
-		if (name == null) {
-			if (other.name != null) {
-				return false;
-			}
-		} else if (!name.equals(other.name)) {
-			return false;
-		}
-		if (service == null) {
-			if (other.service != null) {
+			if (other.id != null)
 				return false;
-			}
-		} else if (!service.equals(other.service)) {
+		} else if (!id.equals(other.id))
 			return false;
-		}
-		if (version == null) {
-			if (other.version != null) {
-				return false;
-			}
-		} else if (!version.equals(other.version)) {
-			return false;
-		}
 		return true;
 	}
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.lang.Object#toString()
-	 */
 	@Override
 	public String toString() {
-		return "XXPolicy [" + super.toString() + " id=" + id + ", guid=" + guid
-				+ ", version=" + version + ", service=" + service + ", name="
-				+ name + ", description=" + description + ", isEnabled="
-				+ isEnabled + ", isAuditEnabled=" + isAuditEnabled + "]";
+		return "XXPolicy [id=" + id + "]";
 	}
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyBase.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyBase.java
new file mode 100644
index 0000000..7ee05c8
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyBase.java
@@ -0,0 +1,287 @@
+package org.apache.ranger.entity;
+
+import javax.persistence.Column;
+import javax.persistence.MappedSuperclass;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@MappedSuperclass
+@XmlRootElement
+public abstract class XXPolicyBase extends XXDBBase {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Global Id for the object
+	 * <ul>
+	 * <li>The maximum length for this attribute is <b>512</b>.
+	 * </ul>
+	 *
+	 */
+	@Column(name = "guid", unique = true, nullable = false, length = 512)
+	protected String guid;
+
+	/**
+	 * version of the XXPolicy
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "version")
+	protected Long version;
+
+	/**
+	 * service of the XXPolicy
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "service")
+	protected Long service;
+
+	/**
+	 * name of the XXPolicy
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "name")
+	protected String name;
+
+	/**
+	 * description of the XXPolicy
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "description")
+	protected String description;
+
+	/**
+	 * isEnabled of the XXPolicy
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "is_enabled")
+	protected boolean isEnabled;
+
+	/**
+	 * isAuditEnabled of the XXPolicy
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "is_audit_enabled")
+	protected boolean isAuditEnabled;
+
+	/**
+	 * @return the gUID
+	 */
+	public String getGuid() {
+		return guid;
+	}
+
+	/**
+	 * @param gUID
+	 *            the gUID to set
+	 */
+	public void setGuid(String gUID) {
+		guid = gUID;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> version</b> . You
+	 * cannot set null to the attribute.
+	 * 
+	 * @param version
+	 *            Value to set member attribute <b> version</b>
+	 */
+	public void setVersion(Long version) {
+		this.version = version;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>version</b>
+	 * 
+	 * @return Date - value of member attribute <b>version</b> .
+	 */
+	public Long getVersion() {
+		return this.version;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> service</b> . You
+	 * cannot set null to the attribute.
+	 * 
+	 * @param service
+	 *            Value to set member attribute <b> service</b>
+	 */
+	public void setService(Long service) {
+		this.service = service;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>service</b>
+	 * 
+	 * @return Date - value of member attribute <b>service</b> .
+	 */
+	public Long getService() {
+		return this.service;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> name</b> . You
+	 * cannot set null to the attribute.
+	 * 
+	 * @param name
+	 *            Value to set member attribute <b> name</b>
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>name</b>
+	 * 
+	 * @return Date - value of member attribute <b>name</b> .
+	 */
+	public String getName() {
+		return this.name;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> description</b> .
+	 * You cannot set null to the attribute.
+	 * 
+	 * @param description
+	 *            Value to set member attribute <b> description</b>
+	 */
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>description</b>
+	 * 
+	 * @return Date - value of member attribute <b>description</b> .
+	 */
+	public String getDescription() {
+		return this.description;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> isEnabled</b> .
+	 * You cannot set null to the attribute.
+	 * 
+	 * @param isEnabled
+	 *            Value to set member attribute <b> isEnabled</b>
+	 */
+	public void setIsEnabled(boolean isEnabled) {
+		this.isEnabled = isEnabled;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>isEnabled</b>
+	 * 
+	 * @return Date - value of member attribute <b>isEnabled</b> .
+	 */
+	public boolean getIsEnabled() {
+		return this.isEnabled;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> isAuditEnabled</b>
+	 * . You cannot set null to the attribute.
+	 * 
+	 * @param isAuditEnabled
+	 *            Value to set member attribute <b> isAuditEnabled</b>
+	 */
+	public void setIsAuditEnabled(boolean isAuditEnabled) {
+		this.isAuditEnabled = isAuditEnabled;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>isAuditEnabled</b>
+	 * 
+	 * @return Date - value of member attribute <b>isAuditEnabled</b> .
+	 */
+	public boolean getIsAuditEnabled() {
+		return this.isAuditEnabled;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj) {
+		if (!super.equals(obj)) {
+			return false;
+		}
+		if (this == obj) {
+			return true;
+		}
+		if (!super.equals(obj)) {
+			return false;
+		}
+		if (getClass() != obj.getClass()) {
+			return false;
+		}
+		XXPolicyBase other = (XXPolicyBase) obj;
+		if (guid == null) {
+			if (other.guid != null) {
+				return false;
+			}
+		} else if (!guid.equals(other.guid)) {
+			return false;
+		}
+		if (description == null) {
+			if (other.description != null) {
+				return false;
+			}
+		} else if (!description.equals(other.description)) {
+			return false;
+		}
+		if (isAuditEnabled != other.isAuditEnabled) {
+			return false;
+		}
+		if (isEnabled != other.isEnabled) {
+			return false;
+		}
+		if (name == null) {
+			if (other.name != null) {
+				return false;
+			}
+		} else if (!name.equals(other.name)) {
+			return false;
+		}
+		if (service == null) {
+			if (other.service != null) {
+				return false;
+			}
+		} else if (!service.equals(other.service)) {
+			return false;
+		}
+		if (version == null) {
+			if (other.version != null) {
+				return false;
+			}
+		} else if (!version.equals(other.version)) {
+			return false;
+		}
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return "XXPolicyBase [" + super.toString() + " guid=" + guid + ", version=" + version + ", service=" + service
+				+ ", name=" + name + ", description=" + description + ", isEnabled=" + isEnabled + ", isAuditEnabled="
+				+ isAuditEnabled + "]";
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyWithAssignedId.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyWithAssignedId.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyWithAssignedId.java
new file mode 100644
index 0000000..b5cf6c3
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyWithAssignedId.java
@@ -0,0 +1,57 @@
+package org.apache.ranger.entity;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@Cacheable
+@XmlRootElement
+@Table(name = "x_policy")
+public class XXPolicyWithAssignedId extends XXPolicyBase {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * id of the XXPolicy
+	 *
+	 */
+	@Id
+	@Column(name = "id")
+	protected Long id;
+
+	@Override
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	@Override
+	public Long getId() {
+		return id;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (!super.equals(obj))
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		XXPolicyWithAssignedId other = (XXPolicyWithAssignedId) obj;
+		if (id == null) {
+			if (other.id != null)
+				return false;
+		} else if (!id.equals(other.id))
+			return false;
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "XXPolicyWithAssignedId [id=" + id + "]";
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/entity/XXService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXService.java b/security-admin/src/main/java/org/apache/ranger/entity/XXService.java
index 9d6cf4d..a1efc94 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXService.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXService.java
@@ -18,8 +18,6 @@
  */
 package org.apache.ranger.entity;
 
-import java.util.Date;
-
 import javax.persistence.*;
 import javax.xml.bind.annotation.XmlRootElement;
 
@@ -27,8 +25,9 @@ import javax.xml.bind.annotation.XmlRootElement;
 @Cacheable
 @XmlRootElement
 @Table(name = "x_service")
-public class XXService extends XXDBBase implements java.io.Serializable {
+public class XXService extends XXServiceBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
+
 	/**
 	 * id of the XXService
 	 * <ul>
@@ -40,351 +39,37 @@ public class XXService extends XXDBBase implements java.io.Serializable {
 	@GeneratedValue(strategy = GenerationType.AUTO, generator = "x_service_SEQ")
 	@Column(name = "id")
 	protected Long id;
-	
-	/**
-	 * Global Id for the object
-	 * <ul>
-	 * <li>The maximum length for this attribute is <b>512</b>.
-	 * </ul>
-	 *
-	 */
-	@Column(name = "guid", unique = true, nullable = false, length = 512)
-	protected String guid;
-
-	/**
-	 * version of the XXServiceDef
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "version")
-	protected Long version;
-
-	/**
-	 * type of the XXService
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "type")
-	protected Long type;
-
-	/**
-	 * name of the XXService
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "name")
-	protected String name;
-
-	/**
-	 * policyVersion of the XXService
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "policy_version")
-	protected Long policyVersion;
 
-	/**
-	 * policyUpdateTime of the XXService
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Temporal(TemporalType.TIMESTAMP)
-	@Column(name = "policy_update_time")
-	protected Date policyUpdateTime;
-
-	/**
-	 * description of the XXService
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "description")
-	protected String description;
-
-	/**
-	 * isEnabled of the XXService
-	 * <ul>
-	 * </ul>
-	 *
-	 */
-	@Column(name = "is_enabled")
-	protected Boolean isEnabled;
-
-	/**
-	 * This method sets the value to the member attribute <b> id</b> . You
-	 * cannot set null to the attribute.
-	 * 
-	 * @param id
-	 *            Value to set member attribute <b> id</b>
-	 */
+	@Override
 	public void setId(Long id) {
 		this.id = id;
 	}
 
-	/**
-	 * Returns the value for the member attribute <b>id</b>
-	 * 
-	 * @return Date - value of member attribute <b>id</b> .
-	 */
+	@Override
 	public Long getId() {
-		return this.id;
-	}
-	
-	/**
-	 * @return the gUID
-	 */
-	public String getGuid() {
-		return this.guid;
-	}
-
-	/**
-	 * @param guid
-	 *            the gUID to set
-	 */
-	public void setGuid(String guid) {
-		this.guid = guid;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> version</b> . You
-	 * cannot set null to the attribute.
-	 * 
-	 * @param version
-	 *            Value to set member attribute <b> version</b>
-	 */
-	public void setVersion(Long version) {
-		this.version = version;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>version</b>
-	 * 
-	 * @return Date - value of member attribute <b>version</b> .
-	 */
-	public Long getVersion() {
-		return this.version;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> type</b> . You
-	 * cannot set null to the attribute.
-	 * 
-	 * @param type
-	 *            Value to set member attribute <b> type</b>
-	 */
-	public void setType(Long type) {
-		this.type = type;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>type</b>
-	 * 
-	 * @return Date - value of member attribute <b>type</b> .
-	 */
-	public Long getType() {
-		return this.type;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> name</b> . You
-	 * cannot set null to the attribute.
-	 * 
-	 * @param name
-	 *            Value to set member attribute <b> name</b>
-	 */
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>name</b>
-	 * 
-	 * @return Date - value of member attribute <b>name</b> .
-	 */
-	public String getName() {
-		return this.name;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> policyVersion</b>
-	 * . You cannot set null to the attribute.
-	 * 
-	 * @param policyVersion
-	 *            Value to set member attribute <b> policyVersion</b>
-	 */
-	public void setPolicyVersion(Long policyVersion) {
-		this.policyVersion = policyVersion;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>policyVersion</b>
-	 * 
-	 * @return Date - value of member attribute <b>policyVersion</b> .
-	 */
-	public Long getPolicyVersion() {
-		return this.policyVersion;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b>
-	 * policyUpdateTime</b> . You cannot set null to the attribute.
-	 * 
-	 * @param policyUpdateTime
-	 *            Value to set member attribute <b> policyUpdateTime</b>
-	 */
-	public void setPolicyUpdateTime(Date policyUpdateTime) {
-		this.policyUpdateTime = policyUpdateTime;
+		return id;
 	}
 
-	/**
-	 * Returns the value for the member attribute <b>policyUpdateTime</b>
-	 * 
-	 * @return Date - value of member attribute <b>policyUpdateTime</b> .
-	 */
-	public Date getPolicyUpdateTime() {
-		return this.policyUpdateTime;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> description</b> .
-	 * You cannot set null to the attribute.
-	 * 
-	 * @param description
-	 *            Value to set member attribute <b> description</b>
-	 */
-	public void setDescription(String description) {
-		this.description = description;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>description</b>
-	 * 
-	 * @return Date - value of member attribute <b>description</b> .
-	 */
-	public String getDescription() {
-		return this.description;
-	}
-
-	/**
-	 * This method sets the value to the member attribute <b> isEnabled</b> .
-	 * You cannot set null to the attribute.
-	 * 
-	 * @param isEnabled
-	 *            Value to set member attribute <b> isEnabled</b>
-	 */
-	public void setIsEnabled(Boolean isEnabled) {
-		this.isEnabled = isEnabled;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>isEnabled</b>
-	 * 
-	 * @return Date - value of member attribute <b>isEnabled</b> .
-	 */
-	public Boolean getIsenabled() {
-		return this.isEnabled;
+	@Override
+	public String toString() {
+		return "XXService [id=" + id + "]";
 	}
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.lang.Object#equals(java.lang.Object)
-	 */
 	@Override
 	public boolean equals(Object obj) {
-		if (!super.equals(obj)) {
-			return false;
-		}
-		if (this == obj) {
+		if (this == obj)
 			return true;
-		}
-		if (getClass() != obj.getClass()) {
+		if (!super.equals(obj))
 			return false;
-		}
-		XXService other = (XXService) obj;
-		if (description == null) {
-			if (other.description != null) {
-				return false;
-			}
-		} else if (!description.equals(other.description)) {
+		if (getClass() != obj.getClass())
 			return false;
-		}
+		XXService other = (XXService) obj;
 		if (id == null) {
-			if (other.id != null) {
-				return false;
-			}
-		} else if (!id.equals(other.id)) {
-			return false;
-		}
-		if (isEnabled == null) {
-			if (other.isEnabled != null) {
+			if (other.id != null)
 				return false;
-			}
-		} else if (!isEnabled.equals(other.isEnabled)) {
+		} else if (!id.equals(other.id))
 			return false;
-		}
-		if (name == null) {
-			if (other.name != null) {
-				return false;
-			}
-		} else if (!name.equals(other.name)) {
-			return false;
-		}
-		if (policyUpdateTime == null) {
-			if (other.policyUpdateTime != null) {
-				return false;
-			}
-		} else if (!policyUpdateTime.equals(other.policyUpdateTime)) {
-			return false;
-		}
-		if (policyVersion == null) {
-			if (other.policyVersion != null) {
-				return false;
-			}
-		} else if (!policyVersion.equals(other.policyVersion)) {
-			return false;
-		}
-		if (type == null) {
-			if (other.type != null) {
-				return false;
-			}
-		} else if (!type.equals(other.type)) {
-			return false;
-		}
-		if (version == null) {
-			if (other.version != null) {
-				return false;
-			}
-		} else if (!version.equals(other.version)) {
-			return false;
-		}
-		if (guid == null) {
-			if (other.guid != null) {
-				return false;
-			}
-		} else if (!guid.equals(other.guid)) {
-			return false;
-		}
 		return true;
 	}
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.lang.Object#toString()
-	 */
-	@Override
-	public String toString() {
-		return "XXService [" + super.toString() + " id=" + id + ", guid="
-				+ guid + ", version=" + version + ", type=" + type + ", name="
-				+ name + ", policyVersion=" + policyVersion
-				+ ", policyUpdateTime=" + policyUpdateTime + ", description="
-				+ description + ", isEnabled=" + isEnabled + "]";
-	}
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/entity/XXServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceBase.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceBase.java
new file mode 100644
index 0000000..ad193d4
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceBase.java
@@ -0,0 +1,333 @@
+package org.apache.ranger.entity;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@MappedSuperclass
+@XmlRootElement
+public abstract class XXServiceBase extends XXDBBase {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Global Id for the object
+	 * <ul>
+	 * <li>The maximum length for this attribute is <b>512</b>.
+	 * </ul>
+	 *
+	 */
+	@Column(name = "guid", unique = true, nullable = false, length = 512)
+	protected String guid;
+
+	/**
+	 * version of the XXServiceDef
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "version")
+	protected Long version;
+
+	/**
+	 * type of the XXService
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "type")
+	protected Long type;
+
+	/**
+	 * name of the XXService
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "name")
+	protected String name;
+
+	/**
+	 * policyVersion of the XXService
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "policy_version")
+	protected Long policyVersion;
+
+	/**
+	 * policyUpdateTime of the XXService
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Temporal(TemporalType.TIMESTAMP)
+	@Column(name = "policy_update_time")
+	protected Date policyUpdateTime;
+
+	/**
+	 * description of the XXService
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "description")
+	protected String description;
+
+	/**
+	 * isEnabled of the XXService
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Column(name = "is_enabled")
+	protected Boolean isEnabled;
+
+	/**
+	 * @return the gUID
+	 */
+	public String getGuid() {
+		return this.guid;
+	}
+
+	/**
+	 * @param guid
+	 *            the gUID to set
+	 */
+	public void setGuid(String guid) {
+		this.guid = guid;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> version</b> . You
+	 * cannot set null to the attribute.
+	 * 
+	 * @param version
+	 *            Value to set member attribute <b> version</b>
+	 */
+	public void setVersion(Long version) {
+		this.version = version;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>version</b>
+	 * 
+	 * @return Date - value of member attribute <b>version</b> .
+	 */
+	public Long getVersion() {
+		return this.version;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> type</b> . You
+	 * cannot set null to the attribute.
+	 * 
+	 * @param type
+	 *            Value to set member attribute <b> type</b>
+	 */
+	public void setType(Long type) {
+		this.type = type;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>type</b>
+	 * 
+	 * @return Date - value of member attribute <b>type</b> .
+	 */
+	public Long getType() {
+		return this.type;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> name</b> . You
+	 * cannot set null to the attribute.
+	 * 
+	 * @param name
+	 *            Value to set member attribute <b> name</b>
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>name</b>
+	 * 
+	 * @return Date - value of member attribute <b>name</b> .
+	 */
+	public String getName() {
+		return this.name;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> policyVersion</b>
+	 * . You cannot set null to the attribute.
+	 * 
+	 * @param policyVersion
+	 *            Value to set member attribute <b> policyVersion</b>
+	 */
+	public void setPolicyVersion(Long policyVersion) {
+		this.policyVersion = policyVersion;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>policyVersion</b>
+	 * 
+	 * @return Date - value of member attribute <b>policyVersion</b> .
+	 */
+	public Long getPolicyVersion() {
+		return this.policyVersion;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b>
+	 * policyUpdateTime</b> . You cannot set null to the attribute.
+	 * 
+	 * @param policyUpdateTime
+	 *            Value to set member attribute <b> policyUpdateTime</b>
+	 */
+	public void setPolicyUpdateTime(Date policyUpdateTime) {
+		this.policyUpdateTime = policyUpdateTime;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>policyUpdateTime</b>
+	 * 
+	 * @return Date - value of member attribute <b>policyUpdateTime</b> .
+	 */
+	public Date getPolicyUpdateTime() {
+		return this.policyUpdateTime;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> description</b> .
+	 * You cannot set null to the attribute.
+	 * 
+	 * @param description
+	 *            Value to set member attribute <b> description</b>
+	 */
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>description</b>
+	 * 
+	 * @return Date - value of member attribute <b>description</b> .
+	 */
+	public String getDescription() {
+		return this.description;
+	}
+
+	/**
+	 * This method sets the value to the member attribute <b> isEnabled</b> .
+	 * You cannot set null to the attribute.
+	 * 
+	 * @param isEnabled
+	 *            Value to set member attribute <b> isEnabled</b>
+	 */
+	public void setIsEnabled(Boolean isEnabled) {
+		this.isEnabled = isEnabled;
+	}
+
+	/**
+	 * Returns the value for the member attribute <b>isEnabled</b>
+	 * 
+	 * @return Date - value of member attribute <b>isEnabled</b> .
+	 */
+	public Boolean getIsenabled() {
+		return this.isEnabled;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj) {
+		if (!super.equals(obj)) {
+			return false;
+		}
+		if (this == obj) {
+			return true;
+		}
+		if (getClass() != obj.getClass()) {
+			return false;
+		}
+		XXServiceBase other = (XXServiceBase) obj;
+		if (description == null) {
+			if (other.description != null) {
+				return false;
+			}
+		} else if (!description.equals(other.description)) {
+			return false;
+		}
+		if (isEnabled == null) {
+			if (other.isEnabled != null) {
+				return false;
+			}
+		} else if (!isEnabled.equals(other.isEnabled)) {
+			return false;
+		}
+		if (name == null) {
+			if (other.name != null) {
+				return false;
+			}
+		} else if (!name.equals(other.name)) {
+			return false;
+		}
+		if (policyUpdateTime == null) {
+			if (other.policyUpdateTime != null) {
+				return false;
+			}
+		} else if (!policyUpdateTime.equals(other.policyUpdateTime)) {
+			return false;
+		}
+		if (policyVersion == null) {
+			if (other.policyVersion != null) {
+				return false;
+			}
+		} else if (!policyVersion.equals(other.policyVersion)) {
+			return false;
+		}
+		if (type == null) {
+			if (other.type != null) {
+				return false;
+			}
+		} else if (!type.equals(other.type)) {
+			return false;
+		}
+		if (version == null) {
+			if (other.version != null) {
+				return false;
+			}
+		} else if (!version.equals(other.version)) {
+			return false;
+		}
+		if (guid == null) {
+			if (other.guid != null) {
+				return false;
+			}
+		} else if (!guid.equals(other.guid)) {
+			return false;
+		}
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return "XXServiceBase [" + super.toString() + " guid=" + guid + ", version=" + version + ", type=" + type
+				+ ", name=" + name + ", policyVersion=" + policyVersion + ", policyUpdateTime=" + policyUpdateTime
+				+ ", description=" + description + ", isEnabled=" + isEnabled + "]";
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/entity/XXServiceWithAssignedId.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceWithAssignedId.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceWithAssignedId.java
new file mode 100644
index 0000000..54e88c6
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceWithAssignedId.java
@@ -0,0 +1,59 @@
+package org.apache.ranger.entity;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@Cacheable
+@XmlRootElement
+@Table(name = "x_service")
+public class XXServiceWithAssignedId extends XXServiceBase {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * id of the XXService
+	 * <ul>
+	 * </ul>
+	 *
+	 */
+	@Id
+	@Column(name = "id")
+	protected Long id;
+
+	@Override
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	@Override
+	public Long getId() {
+		return id;
+	}
+	
+	@Override
+	public String toString() {
+		return "XXService [id=" + id + "]";
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (!super.equals(obj))
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		XXServiceWithAssignedId other = (XXServiceWithAssignedId) obj;
+		if (id == null) {
+			if (other.id != null)
+				return false;
+		} else if (!id.equals(other.id))
+			return false;
+		return true;
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/patch/PatchMigration_J10002.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/patch/PatchMigration_J10002.java b/security-admin/src/main/java/org/apache/ranger/patch/PatchMigration_J10002.java
index 34b6541..7b97cc1 100644
--- a/security-admin/src/main/java/org/apache/ranger/patch/PatchMigration_J10002.java
+++ b/security-admin/src/main/java/org/apache/ranger/patch/PatchMigration_J10002.java
@@ -7,6 +7,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.log4j.Logger;
+import org.apache.ranger.biz.RangerBizUtil;
 import org.apache.ranger.biz.ServiceDBStore;
 import org.apache.ranger.common.AppConstants;
 import org.apache.ranger.common.JSONUtil;
@@ -62,6 +63,9 @@ public class PatchMigration_J10002 extends BaseLoader {
 
 	@Autowired
 	XPermMapService xPermMapService;
+	
+	@Autowired
+	RangerBizUtil bizUtil;
 
 	private static int policyCounter = 0;
 	private static int serviceCounter = 0;
@@ -93,6 +97,7 @@ public class PatchMigration_J10002 extends BaseLoader {
 		try {
 			migrateServicesToNewSchema();
 			migratePoliciesToNewSchema();
+			updateSequences();
 		} catch (Exception e) {
 			logger.error("Error whille migrating data.", e);
 		}
@@ -410,5 +415,49 @@ public class PatchMigration_J10002 extends BaseLoader {
 		}
 		return policyItems;
 	}
+	
+	private void updateSequences() {
+		
+		if(RangerBizUtil.getDBFlavor() != AppConstants.DB_FLAVOR_ORACLE) {
+			return;
+		}
+		
+		List<String> queryList = new ArrayList<String>();
+		String policySequence = "X_POLICY_SEQ";
+		String svcSequence = "X_SERVICE_SEQ";
+		
+		if(serviceCounter > 0) {
+			
+			Long maxSvcId = daoMgr.getXXService().getMaxIdOfXXService();
+			
+			if(maxSvcId != null) {
+				String query1 = "ALTER SEQUENCE " + svcSequence + " INCREMENT BY " + maxSvcId;
+				String query2 = "select " + svcSequence + ".nextval from dual";
+				String query3 = "ALTER SEQUENCE " + svcSequence + " INCREMENT BY 1 NOCACHE NOCYCLE";
+				queryList.add(query1);
+				queryList.add(query2);
+				queryList.add(query3);
+			}
+		}
+		
+		if(policyCounter > 0) {
+			
+			Long maxPolId = daoMgr.getXXPolicy().getMaxIdOfXXPolicy();
+			
+			if(maxPolId != null) {				
+				String query1 = "ALTER SEQUENCE " + policySequence + " INCREMENT BY " + maxPolId;
+				String query2 = "select " + policySequence + ".nextval from dual";
+				String query3 = "ALTER SEQUENCE " + policySequence + " INCREMENT BY 1 NOCACHE NOCYCLE";
+				queryList.add(query1);
+				queryList.add(query2);
+				queryList.add(query3);
+			}
+		}
+		
+		for(String query : queryList) {
+			daoMgr.getEntityManager().createNativeQuery(query).executeUpdate();
+		}
+		
+	}
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
index 3193407..3fef565 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
@@ -10,30 +10,14 @@ import java.util.Map;
 import org.apache.ranger.common.AppConstants;
 import org.apache.ranger.common.JSONUtil;
 import org.apache.ranger.common.MessageEnums;
-import org.apache.ranger.common.SearchField;
-import org.apache.ranger.common.SortField;
-import org.apache.ranger.common.SearchField.DATA_TYPE;
-import org.apache.ranger.common.SearchField.SEARCH_TYPE;
 import org.apache.ranger.common.view.VTrxLogAttr;
-import org.apache.ranger.db.XXAccessTypeDefDao;
-import org.apache.ranger.db.XXPolicyResourceDao;
-import org.apache.ranger.entity.XXAccessTypeDef;
 import org.apache.ranger.entity.XXPolicy;
-import org.apache.ranger.entity.XXPolicyConditionDef;
-import org.apache.ranger.entity.XXPolicyItem;
-import org.apache.ranger.entity.XXPolicyItemAccess;
-import org.apache.ranger.entity.XXPolicyItemCondition;
-import org.apache.ranger.entity.XXPolicyResource;
-import org.apache.ranger.entity.XXPolicyResourceMap;
-import org.apache.ranger.entity.XXResourceDef;
+import org.apache.ranger.entity.XXPolicyBase;
 import org.apache.ranger.entity.XXService;
 import org.apache.ranger.entity.XXTrxLog;
 import org.apache.ranger.plugin.model.RangerPolicy;
 import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem;
-import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess;
-import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemCondition;
 import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
-import org.apache.ranger.plugin.util.SearchFilter;
 import org.codehaus.jackson.JsonParseException;
 import org.codehaus.jackson.map.JsonMappingException;
 import org.codehaus.jackson.map.ObjectMapper;
@@ -70,33 +54,16 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range
 		actionCreate = "create";
 		actionUpdate = "update";
 		actionDelete = "delete";
-		
-		searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE, "xSvcDef.name", DATA_TYPE.STRING, 
-				SEARCH_TYPE.FULL, "XXServiceDef xSvcDef, XXService xSvc", "xSvc.type = xSvcDef.id and xSvc.id = obj.service"));
-		searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE_ID, "xSvc.type", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL, 
-				"XXService xSvc", "xSvc.id = obj.service"));
-		searchFields.add(new SearchField(SearchFilter.SERVICE_NAME, "xSvc.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL, 
-				"XXService xSvc", "xSvc.id = obj.service"));
-		searchFields.add(new SearchField(SearchFilter.SERVICE_ID, "xSvc.id", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL, 
-				"XXService xSvc", "xSvc.id = obj.service"));
-		searchFields.add(new SearchField(SearchFilter.IS_ENABLED, "obj.isEnabled", DATA_TYPE.BOOLEAN, SEARCH_TYPE.FULL));
-		searchFields.add(new SearchField(SearchFilter.POLICY_ID, "obj.id", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
-		searchFields.add(new SearchField(SearchFilter.POLICY_NAME, "obj.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL));
-		searchFields.add(new SearchField(SearchFilter.USER, "xUser.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL, 
-				"XXUser xUser, XXPolicyItem xPolItem, XXPolicyItemUserPerm userPerm", "obj.id = xPolItem.policyId "
-						+ "and userPerm.policyItemId = xPolItem.id and xUser.id = userPerm.userId"));
-		searchFields.add(new SearchField(SearchFilter.GROUP, "xGrp.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL, 
-				"XXGroup xGrp, XXPolicyItem xPolItem, XXPolicyItemGroupPerm grpPerm", "obj.id = xPolItem.policyId "
-						+ "and grpPerm.policyItemId = xPolItem.id and xGrp.id = grpPerm.groupId"));
-		searchFields.add(new SearchField(SearchFilter.POL_RESOURCE, "resMap.value", DATA_TYPE.STRING,
-				SEARCH_TYPE.PARTIAL, "XXPolicyResourceMap resMap, XXPolicyResource polRes",
-				"resMap.resourceId = polRes.id and polRes.policyId = obj.id"));
-		searchFields.add(new SearchField(SearchFilter.POLICY_NAME_PARTIAL, "obj.name", DATA_TYPE.STRING, SEARCH_TYPE.PARTIAL));
-		
-		sortFields.add(new SortField(SearchFilter.CREATE_TIME, "obj.createTime"));
-		sortFields.add(new SortField(SearchFilter.UPDATE_TIME, "obj.updateTime"));
-		sortFields.add(new SortField(SearchFilter.POLICY_ID, "obj.id"));
-		sortFields.add(new SortField(SearchFilter.POLICY_NAME, "obj.name"));
+	}
+
+	@Override
+	protected XXPolicy mapViewToEntityBean(RangerPolicy vObj, XXPolicy xObj, int OPERATION_CONTEXT) {
+		return (XXPolicy)super.mapViewToEntityBean(vObj, (XXPolicyBase)xObj, OPERATION_CONTEXT);
+	}
+
+	@Override
+	protected RangerPolicy mapEntityToViewBean(RangerPolicy vObj, XXPolicy xObj) {
+		return super.mapEntityToViewBean(vObj, (XXPolicyBase)xObj);
 	}
 	
 	@Override
@@ -124,98 +91,6 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range
 		return vPolicy;
 	}
 	
-	public List<RangerPolicyItem> getPolicyItemListForXXPolicy(XXPolicy xPolicy) {
-		
-		List<RangerPolicyItem> policyItems = new ArrayList<RangerPolicyItem>();
-		List<XXPolicyItem> xPolicyItemList = daoMgr.getXXPolicyItem().findByPolicyId(xPolicy.getId());
-		
-		for(XXPolicyItem xPolItem : xPolicyItemList) {
-			RangerPolicyItem policyItem = populateXXToRangerPolicyItem(xPolItem);
-			policyItems.add(policyItem);
-		}
-		return policyItems;
-	}
-
-	public RangerPolicyItem populateXXToRangerPolicyItem(XXPolicyItem xPolItem) {
-		
-		RangerPolicyItem rangerPolItem = new RangerPolicyItem();
-		
-		List<XXPolicyItemAccess> xPolItemAccList = daoMgr
-				.getXXPolicyItemAccess().findByPolicyItemId(xPolItem.getId());
-		List<RangerPolicyItemAccess> accesses = new ArrayList<RangerPolicyItemAccess>();
-		
-		XXAccessTypeDefDao xAccDefDao = daoMgr.getXXAccessTypeDef();
-		for(XXPolicyItemAccess xPolAccess : xPolItemAccList) {
-			RangerPolicyItemAccess access = new RangerPolicyItemAccess();
-			access.setIsAllowed(xPolAccess.getIsallowed());
-			XXAccessTypeDef xAccessType = xAccDefDao.getById(xPolAccess.getType());
-			access.setType(xAccessType.getName());
-			
-			accesses.add(access);
-		}
-		rangerPolItem.setAccesses(accesses);
-		
-		List<RangerPolicyItemCondition> conditions = new ArrayList<RangerPolicyItemCondition>();
-		List<XXPolicyConditionDef> xConditionDefList = daoMgr
-				.getXXPolicyConditionDef()
-				.findByPolicyItemId(xPolItem.getId());
-		for(XXPolicyConditionDef xCondDef : xConditionDefList) {
-			
-			List<XXPolicyItemCondition> xPolCondItemList = daoMgr
-					.getXXPolicyItemCondition().findByPolicyItemAndDefId(
-							xPolItem.getId(), xCondDef.getId());
-			List<String> values = new ArrayList<String>();
-			
-			for(XXPolicyItemCondition polCond : xPolCondItemList) {
-				values.add(polCond.getValue());
-			}
-			
-			RangerPolicyItemCondition condition = new RangerPolicyItemCondition();
-			condition.setType(xCondDef.getName());
-			condition.setValues(values);
-			
-			conditions.add(condition);
-		}
-		rangerPolItem.setConditions(conditions);
-		
-		List<String> userList = daoMgr.getXXUser().findByPolicyItemId(xPolItem.getId());
-		List<String> grpList = daoMgr.getXXGroup().findByPolicyItemId(xPolItem.getId());
-		
-		rangerPolItem.setUsers(userList);
-		rangerPolItem.setGroups(grpList);
-		
-		rangerPolItem.setDelegateAdmin(xPolItem.getDelegateAdmin());
-		return rangerPolItem;
-	}
-
-	public Map<String, RangerPolicyResource> getResourcesForXXPolicy(XXPolicy xPolicy) {
-		List<XXResourceDef> resDefList = daoMgr.getXXResourceDef().findByPolicyId(xPolicy.getId());
-		Map<String, RangerPolicyResource> resources = new HashMap<String, RangerPolicyResource>();
-		
-		XXPolicyResourceDao xPolResDao = daoMgr.getXXPolicyResource();
-		for(XXResourceDef xResDef : resDefList) {
-			XXPolicyResource xPolRes = xPolResDao.findByResDefIdAndPolicyId(
-					xResDef.getId(), xPolicy.getId());
-			if(xPolRes == null) {
-				continue;
-			}
-			List<String> values = new ArrayList<>();
-			List<XXPolicyResourceMap> xPolResMapList = daoMgr
-					.getXXPolicyResourceMap()
-					.findByPolicyResId(xPolRes.getId());
-			for(XXPolicyResourceMap xPolResMap : xPolResMapList) {
-				values.add(xPolResMap.getValue());
-			}
-			RangerPolicyResource resource = new RangerPolicyResource();
-			resource.setValues(values);
-			resource.setIsExcludes(xPolRes.getIsexcludes());
-			resource.setIsRecursive(xPolRes.getIsrecursive());
-			
-			resources.put(xResDef.getName(), resource);
-		}
-		return resources;
-	}
-	
 	public RangerPolicy getPopulatedViewObject(XXPolicy xPolicy) {
 		return this.populateViewBean(xPolicy);
 	}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyServiceBase.java b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyServiceBase.java
index 58c2b69..290d85c 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyServiceBase.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyServiceBase.java
@@ -1,46 +1,98 @@
 package org.apache.ranger.service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.ranger.common.GUIDUtil;
 import org.apache.ranger.common.MessageEnums;
+import org.apache.ranger.common.SearchField;
+import org.apache.ranger.common.SortField;
+import org.apache.ranger.common.SearchField.DATA_TYPE;
+import org.apache.ranger.common.SearchField.SEARCH_TYPE;
+import org.apache.ranger.db.XXAccessTypeDefDao;
+import org.apache.ranger.db.XXPolicyResourceDao;
+import org.apache.ranger.entity.XXAccessTypeDef;
 import org.apache.ranger.entity.XXPolicy;
+import org.apache.ranger.entity.XXPolicyBase;
+import org.apache.ranger.entity.XXPolicyConditionDef;
+import org.apache.ranger.entity.XXPolicyItem;
+import org.apache.ranger.entity.XXPolicyItemAccess;
+import org.apache.ranger.entity.XXPolicyItemCondition;
+import org.apache.ranger.entity.XXPolicyResource;
+import org.apache.ranger.entity.XXPolicyResourceMap;
+import org.apache.ranger.entity.XXResourceDef;
 import org.apache.ranger.entity.XXService;
 import org.apache.ranger.plugin.model.RangerPolicy;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemCondition;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
 import org.apache.ranger.plugin.util.SearchFilter;
 import org.apache.ranger.view.RangerPolicyList;
 
-public abstract class RangerPolicyServiceBase<T extends XXPolicy, V extends RangerPolicy> extends RangerBaseModelService<T, V> {
-	
+public abstract class RangerPolicyServiceBase<T extends XXPolicyBase, V extends RangerPolicy> extends
+		RangerBaseModelService<T, V> {
+
+	public RangerPolicyServiceBase() {
+		super();
+		searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE, "xSvcDef.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL,
+				"XXServiceDef xSvcDef, XXService xSvc", "xSvc.type = xSvcDef.id and xSvc.id = obj.service"));
+		searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE_ID, "xSvc.type", DATA_TYPE.INTEGER,
+				SEARCH_TYPE.FULL, "XXService xSvc", "xSvc.id = obj.service"));
+		searchFields.add(new SearchField(SearchFilter.SERVICE_NAME, "xSvc.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL,
+				"XXService xSvc", "xSvc.id = obj.service"));
+		searchFields.add(new SearchField(SearchFilter.SERVICE_ID, "xSvc.id", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL,
+				"XXService xSvc", "xSvc.id = obj.service"));
+		searchFields
+				.add(new SearchField(SearchFilter.IS_ENABLED, "obj.isEnabled", DATA_TYPE.BOOLEAN, SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField(SearchFilter.POLICY_ID, "obj.id", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField(SearchFilter.POLICY_NAME, "obj.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField(SearchFilter.USER, "xUser.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL,
+				"XXUser xUser, XXPolicyItem xPolItem, XXPolicyItemUserPerm userPerm", "obj.id = xPolItem.policyId "
+						+ "and userPerm.policyItemId = xPolItem.id and xUser.id = userPerm.userId"));
+		searchFields.add(new SearchField(SearchFilter.GROUP, "xGrp.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL,
+				"XXGroup xGrp, XXPolicyItem xPolItem, XXPolicyItemGroupPerm grpPerm", "obj.id = xPolItem.policyId "
+						+ "and grpPerm.policyItemId = xPolItem.id and xGrp.id = grpPerm.groupId"));
+		searchFields.add(new SearchField(SearchFilter.POL_RESOURCE, "resMap.value", DATA_TYPE.STRING,
+				SEARCH_TYPE.PARTIAL, "XXPolicyResourceMap resMap, XXPolicyResource polRes",
+				"resMap.resourceId = polRes.id and polRes.policyId = obj.id"));
+		searchFields.add(new SearchField(SearchFilter.POLICY_NAME_PARTIAL, "obj.name", DATA_TYPE.STRING,
+				SEARCH_TYPE.PARTIAL));
+
+		sortFields.add(new SortField(SearchFilter.CREATE_TIME, "obj.createTime"));
+		sortFields.add(new SortField(SearchFilter.UPDATE_TIME, "obj.updateTime"));
+		sortFields.add(new SortField(SearchFilter.POLICY_ID, "obj.id"));
+		sortFields.add(new SortField(SearchFilter.POLICY_NAME, "obj.name"));
+	}
+
 	@Override
 	@SuppressWarnings("unchecked")
-	protected XXPolicy mapViewToEntityBean(RangerPolicy vObj, XXPolicy xObj, int OPERATION_CONTEXT) {
+	protected XXPolicyBase mapViewToEntityBean(RangerPolicy vObj, XXPolicyBase xObj, int OPERATION_CONTEXT) {
 		String guid = (StringUtils.isEmpty(vObj.getGuid())) ? GUIDUtil.genGUI() : vObj.getGuid();
-		
+
 		xObj.setGuid(guid);
 		xObj.setVersion(vObj.getVersion());
-		
+
 		XXService xService = daoMgr.getXXService().findByName(vObj.getService());
-		if(xService == null) {
-			throw restErrorUtil.createRESTException(
-					"No corresponding service found for policyName: "
-							+ vObj.getName() + "Service Not Found : "
-							+ vObj.getName(), MessageEnums.INVALID_INPUT_DATA);
+		if (xService == null) {
+			throw restErrorUtil.createRESTException("No corresponding service found for policyName: " + vObj.getName()
+					+ "Service Not Found : " + vObj.getName(), MessageEnums.INVALID_INPUT_DATA);
 		}
 		xObj.setService(xService.getId());
 		xObj.setName(vObj.getName());
 		xObj.setDescription(vObj.getDescription());
 		xObj.setIsAuditEnabled(vObj.getIsAuditEnabled());
 		xObj.setIsEnabled(vObj.getIsEnabled());
-		
+
 		return xObj;
 	}
 
 	@Override
 	@SuppressWarnings("unchecked")
-	protected RangerPolicy mapEntityToViewBean(RangerPolicy vObj, XXPolicy xObj) {
+	protected RangerPolicy mapEntityToViewBean(RangerPolicy vObj, XXPolicyBase xObj) {
 		XXService xService = daoMgr.getXXService().getById(xObj.getService());
 		vObj.setGuid(xObj.getGuid());
 		vObj.setVersion(xObj.getVersion());
@@ -56,7 +108,7 @@ public abstract class RangerPolicyServiceBase<T extends XXPolicy, V extends Rang
 	public RangerPolicyList searchRangerPolicies(SearchFilter searchFilter) {
 		List<RangerPolicy> policyList = new ArrayList<RangerPolicy>();
 		RangerPolicyList retList = new RangerPolicyList();
-		
+
 		List<XXPolicy> xPolList = (List<XXPolicy>) searchResources(searchFilter, searchFields, sortFields, retList);
 		for (XXPolicy xPol : xPolList) {
 			policyList.add(populateViewBean((T) xPol));
@@ -66,4 +118,91 @@ public abstract class RangerPolicyServiceBase<T extends XXPolicy, V extends Rang
 		return retList;
 	}
 
+	public List<RangerPolicyItem> getPolicyItemListForXXPolicy(XXPolicyBase xPolicy) {
+
+		List<RangerPolicyItem> policyItems = new ArrayList<RangerPolicyItem>();
+		List<XXPolicyItem> xPolicyItemList = daoMgr.getXXPolicyItem().findByPolicyId(xPolicy.getId());
+
+		for (XXPolicyItem xPolItem : xPolicyItemList) {
+			RangerPolicyItem policyItem = populateXXToRangerPolicyItem(xPolItem);
+			policyItems.add(policyItem);
+		}
+		return policyItems;
+	}
+
+	public RangerPolicyItem populateXXToRangerPolicyItem(XXPolicyItem xPolItem) {
+
+		RangerPolicyItem rangerPolItem = new RangerPolicyItem();
+
+		List<XXPolicyItemAccess> xPolItemAccList = daoMgr.getXXPolicyItemAccess().findByPolicyItemId(xPolItem.getId());
+		List<RangerPolicyItemAccess> accesses = new ArrayList<RangerPolicyItemAccess>();
+
+		XXAccessTypeDefDao xAccDefDao = daoMgr.getXXAccessTypeDef();
+		for (XXPolicyItemAccess xPolAccess : xPolItemAccList) {
+			RangerPolicyItemAccess access = new RangerPolicyItemAccess();
+			access.setIsAllowed(xPolAccess.getIsallowed());
+			XXAccessTypeDef xAccessType = xAccDefDao.getById(xPolAccess.getType());
+			access.setType(xAccessType.getName());
+
+			accesses.add(access);
+		}
+		rangerPolItem.setAccesses(accesses);
+
+		List<RangerPolicyItemCondition> conditions = new ArrayList<RangerPolicyItemCondition>();
+		List<XXPolicyConditionDef> xConditionDefList = daoMgr.getXXPolicyConditionDef().findByPolicyItemId(
+				xPolItem.getId());
+		for (XXPolicyConditionDef xCondDef : xConditionDefList) {
+
+			List<XXPolicyItemCondition> xPolCondItemList = daoMgr.getXXPolicyItemCondition().findByPolicyItemAndDefId(
+					xPolItem.getId(), xCondDef.getId());
+			List<String> values = new ArrayList<String>();
+
+			for (XXPolicyItemCondition polCond : xPolCondItemList) {
+				values.add(polCond.getValue());
+			}
+
+			RangerPolicyItemCondition condition = new RangerPolicyItemCondition();
+			condition.setType(xCondDef.getName());
+			condition.setValues(values);
+
+			conditions.add(condition);
+		}
+		rangerPolItem.setConditions(conditions);
+
+		List<String> userList = daoMgr.getXXUser().findByPolicyItemId(xPolItem.getId());
+		List<String> grpList = daoMgr.getXXGroup().findByPolicyItemId(xPolItem.getId());
+
+		rangerPolItem.setUsers(userList);
+		rangerPolItem.setGroups(grpList);
+
+		rangerPolItem.setDelegateAdmin(xPolItem.getDelegateAdmin());
+		return rangerPolItem;
+	}
+
+	public Map<String, RangerPolicyResource> getResourcesForXXPolicy(XXPolicyBase xPolicy) {
+		List<XXResourceDef> resDefList = daoMgr.getXXResourceDef().findByPolicyId(xPolicy.getId());
+		Map<String, RangerPolicyResource> resources = new HashMap<String, RangerPolicyResource>();
+
+		XXPolicyResourceDao xPolResDao = daoMgr.getXXPolicyResource();
+		for (XXResourceDef xResDef : resDefList) {
+			XXPolicyResource xPolRes = xPolResDao.findByResDefIdAndPolicyId(xResDef.getId(), xPolicy.getId());
+			if (xPolRes == null) {
+				continue;
+			}
+			List<String> values = new ArrayList<>();
+			List<XXPolicyResourceMap> xPolResMapList = daoMgr.getXXPolicyResourceMap().findByPolicyResId(
+					xPolRes.getId());
+			for (XXPolicyResourceMap xPolResMap : xPolResMapList) {
+				values.add(xPolResMap.getValue());
+			}
+			RangerPolicyResource resource = new RangerPolicyResource();
+			resource.setValues(values);
+			resource.setIsExcludes(xPolRes.getIsexcludes());
+			resource.setIsRecursive(xPolRes.getIsrecursive());
+
+			resources.put(xResDef.getName(), resource);
+		}
+		return resources;
+	}
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyWithAssignedIdService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyWithAssignedIdService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyWithAssignedIdService.java
new file mode 100644
index 0000000..589fc44
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyWithAssignedIdService.java
@@ -0,0 +1,61 @@
+package org.apache.ranger.service;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ranger.common.JSONUtil;
+import org.apache.ranger.entity.XXPolicyBase;
+import org.apache.ranger.entity.XXPolicyWithAssignedId;
+import org.apache.ranger.plugin.model.RangerPolicy;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class RangerPolicyWithAssignedIdService extends RangerPolicyServiceBase<XXPolicyWithAssignedId, RangerPolicy> {
+
+	@Autowired
+	JSONUtil jsonUtil;
+
+	@Override
+	protected XXPolicyWithAssignedId mapViewToEntityBean(RangerPolicy vObj, XXPolicyWithAssignedId xObj,
+			int OPERATION_CONTEXT) {
+		return (XXPolicyWithAssignedId) super.mapViewToEntityBean(vObj, (XXPolicyBase) xObj, OPERATION_CONTEXT);
+	}
+
+	@Override
+	protected RangerPolicy mapEntityToViewBean(RangerPolicy vObj, XXPolicyWithAssignedId xObj) {
+		return super.mapEntityToViewBean(vObj, (XXPolicyBase) xObj);
+	}
+
+	@Override
+	protected void validateForCreate(RangerPolicy vObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	protected void validateForUpdate(RangerPolicy vObj, XXPolicyWithAssignedId entityObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	protected RangerPolicy populateViewBean(XXPolicyWithAssignedId xPolicy) {
+		RangerPolicy vPolicy = super.populateViewBean(xPolicy);
+
+		Map<String, RangerPolicyResource> resources = getResourcesForXXPolicy(xPolicy);
+		vPolicy.setResources(resources);
+
+		List<RangerPolicyItem> policyItems = getPolicyItemListForXXPolicy(xPolicy);
+		vPolicy.setPolicyItems(policyItems);
+
+		return vPolicy;
+	}
+
+	public RangerPolicy getPopulatedViewObject(XXPolicyWithAssignedId xPolicy) {
+		return this.populateViewBean(xPolicy);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/service/RangerServiceService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceService.java
index 9d1ebd6..cbfb810 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceService.java
@@ -10,18 +10,13 @@ import java.util.Map.Entry;
 import org.apache.ranger.common.AppConstants;
 import org.apache.ranger.common.JSONUtil;
 import org.apache.ranger.common.PropertiesUtil;
-import org.apache.ranger.common.SearchField;
-import org.apache.ranger.common.SearchField.DATA_TYPE;
-import org.apache.ranger.common.SearchField.SEARCH_TYPE;
-import org.apache.ranger.common.SearchUtil;
-import org.apache.ranger.common.SortField;
 import org.apache.ranger.common.view.VTrxLogAttr;
 import org.apache.ranger.entity.XXService;
+import org.apache.ranger.entity.XXServiceBase;
 import org.apache.ranger.entity.XXServiceConfigMap;
 import org.apache.ranger.entity.XXServiceDef;
 import org.apache.ranger.entity.XXTrxLog;
 import org.apache.ranger.plugin.model.RangerService;
-import org.apache.ranger.plugin.util.SearchFilter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
@@ -52,18 +47,16 @@ public class RangerServiceService extends RangerServiceServiceBase<XXService, Ra
 		actionCreate = "create";
 		actionUpdate = "update";
 		actionDelete = "delete";
-		
-		searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE, "xSvcDef.name", DATA_TYPE.STRING, 
-				SEARCH_TYPE.FULL, "XXServiceDef xSvcDef", "obj.type = xSvcDef.id"));
-		searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE_ID, "obj.type", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
-		searchFields.add(new SearchField(SearchFilter.SERVICE_NAME, "obj.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL));
-		searchFields.add(new SearchField(SearchFilter.SERVICE_ID, "obj.id", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
-		searchFields.add(new SearchField(SearchFilter.IS_ENABLED, "obj.isEnabled", DATA_TYPE.BOOLEAN, SEARCH_TYPE.FULL));
-		
-		sortFields.add(new SortField(SearchFilter.CREATE_TIME, "obj.createTime"));
-		sortFields.add(new SortField(SearchFilter.UPDATE_TIME, "obj.updateTime"));
-		sortFields.add(new SortField(SearchFilter.SERVICE_ID, "obj.id"));
-		sortFields.add(new SortField(SearchFilter.SERVICE_NAME, "obj.name"));
+	}
+
+	@Override
+	protected XXService mapViewToEntityBean(RangerService vObj, XXService xObj, int OPERATION_CONTEXT) {
+		return (XXService)super.mapViewToEntityBean(vObj, (XXServiceBase)xObj, OPERATION_CONTEXT);
+	}
+
+	@Override
+	protected RangerService mapEntityToViewBean(RangerService vObj, XXService xObj) {
+		return super.mapEntityToViewBean(vObj, (XXServiceBase)xObj);
 	}
 	
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/service/RangerServiceServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceServiceBase.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceServiceBase.java
index fb6142e..ad318fd 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceServiceBase.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceServiceBase.java
@@ -6,17 +6,39 @@ import java.util.List;
 import org.apache.commons.lang.StringUtils;
 import org.apache.ranger.common.GUIDUtil;
 import org.apache.ranger.common.MessageEnums;
+import org.apache.ranger.common.SearchField;
+import org.apache.ranger.common.SortField;
+import org.apache.ranger.common.SearchField.DATA_TYPE;
+import org.apache.ranger.common.SearchField.SEARCH_TYPE;
 import org.apache.ranger.entity.XXService;
+import org.apache.ranger.entity.XXServiceBase;
 import org.apache.ranger.entity.XXServiceDef;
 import org.apache.ranger.plugin.model.RangerService;
 import org.apache.ranger.plugin.util.SearchFilter;
 import org.apache.ranger.view.RangerServiceList;
 
-public abstract class RangerServiceServiceBase<T extends XXService, V extends RangerService> extends RangerBaseModelService<T, V> {
+public abstract class RangerServiceServiceBase<T extends XXServiceBase, V extends RangerService> extends RangerBaseModelService<T, V> {
+	
+	public RangerServiceServiceBase() {
+		super();
+		
+		searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE, "xSvcDef.name", DATA_TYPE.STRING, 
+				SEARCH_TYPE.FULL, "XXServiceDef xSvcDef", "obj.type = xSvcDef.id"));
+		searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE_ID, "obj.type", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField(SearchFilter.SERVICE_NAME, "obj.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField(SearchFilter.SERVICE_ID, "obj.id", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField(SearchFilter.IS_ENABLED, "obj.isEnabled", DATA_TYPE.BOOLEAN, SEARCH_TYPE.FULL));
+		
+		sortFields.add(new SortField(SearchFilter.CREATE_TIME, "obj.createTime"));
+		sortFields.add(new SortField(SearchFilter.UPDATE_TIME, "obj.updateTime"));
+		sortFields.add(new SortField(SearchFilter.SERVICE_ID, "obj.id"));
+		sortFields.add(new SortField(SearchFilter.SERVICE_NAME, "obj.name"));
+		
+	}
 	
 	@Override
 	@SuppressWarnings("unchecked")
-	protected XXService mapViewToEntityBean(RangerService vObj, XXService xObj, int OPERATION_CONTEXT) {
+	protected XXServiceBase mapViewToEntityBean(RangerService vObj, XXServiceBase xObj, int OPERATION_CONTEXT) {
 		String guid = (StringUtils.isEmpty(vObj.getGuid())) ? GUIDUtil.genGUI() : vObj.getGuid();
 		
 		xObj.setGuid(guid);
@@ -39,7 +61,7 @@ public abstract class RangerServiceServiceBase<T extends XXService, V extends Ra
 
 	@Override
 	@SuppressWarnings("unchecked")
-	protected RangerService mapEntityToViewBean(RangerService vObj, XXService xObj) {
+	protected RangerService mapEntityToViewBean(RangerService vObj, XXServiceBase xObj) {
 		XXServiceDef xServiceDef = daoMgr.getXXServiceDef().getById(xObj.getType());
 		vObj.setType(xServiceDef.getName());
 		vObj.setGuid(xObj.getGuid());

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/java/org/apache/ranger/service/RangerServiceWithAssignedIdService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceWithAssignedIdService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceWithAssignedIdService.java
new file mode 100644
index 0000000..5ba3f54
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceWithAssignedIdService.java
@@ -0,0 +1,60 @@
+package org.apache.ranger.service;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.ranger.common.JSONUtil;
+import org.apache.ranger.entity.XXServiceBase;
+import org.apache.ranger.entity.XXServiceWithAssignedId;
+import org.apache.ranger.entity.XXServiceConfigMap;
+import org.apache.ranger.plugin.model.RangerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class RangerServiceWithAssignedIdService extends RangerServiceServiceBase<XXServiceWithAssignedId, RangerService> {
+
+	@Autowired
+	JSONUtil jsonUtil;
+
+	@Override
+	protected XXServiceWithAssignedId mapViewToEntityBean(RangerService vObj, XXServiceWithAssignedId xObj, int OPERATION_CONTEXT) {
+		return (XXServiceWithAssignedId)super.mapViewToEntityBean(vObj, (XXServiceBase)xObj, OPERATION_CONTEXT);
+	}
+
+	@Override
+	protected RangerService mapEntityToViewBean(RangerService vObj, XXServiceWithAssignedId xObj) {
+		return super.mapEntityToViewBean(vObj, (XXServiceBase)xObj);
+	}
+	
+	@Override
+	protected void validateForCreate(RangerService vObj) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	protected void validateForUpdate(RangerService vService, XXServiceWithAssignedId xService) {
+		
+	}
+	
+	@Override
+	protected RangerService populateViewBean(XXServiceWithAssignedId xService) {
+		RangerService vService = super.populateViewBean(xService);
+		
+		HashMap<String, String> configs = new HashMap<String, String>();
+		List<XXServiceConfigMap> svcConfigMapList = daoMgr.getXXServiceConfigMap()
+				.findByServiceId(xService.getId());
+		for(XXServiceConfigMap svcConfMap : svcConfigMapList) {
+			configs.put(svcConfMap.getConfigkey(), svcConfMap.getConfigvalue());
+		}
+		vService.setConfigs(configs);
+		
+		return vService;
+	}
+	
+	public RangerService getPopulatedViewObject(XXServiceWithAssignedId xService) {
+		return this.populateViewBean(xService);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/53709aad/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
----------------------------------------------------------------------
diff --git a/security-admin/src/main/resources/META-INF/jpa_named_queries.xml b/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
index b94ef13..6a3d795 100644
--- a/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
+++ b/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
@@ -207,6 +207,10 @@
 	<named-query name="XXPolicy.findByServiceId">
 		<query>select obj from XXPolicy obj where obj.service = :serviceId</query>
 	</named-query>
+	
+	<named-query name="XXPolicy.getMaxIdOfXXPolicy">
+		<query>select MAX(obj.id) from XXPolicy obj</query>
+	</named-query>
 
 	<!-- XXServiceDef -->
 	<named-query name="XXServiceDef.findByName">
@@ -315,6 +319,10 @@
 	<named-query name="XXService.findByName">
 		<query>select obj from XXService obj where obj.name = :name</query>
 	</named-query>
+	
+	<named-query name="XXService.getMaxIdOfXXService">
+		<query>select MAX(obj.id) from XXService obj</query>
+	</named-query>
 
 	<!-- XXPolicyResource -->
 	<named-query name="XXPolicyResource.findByResDefIdAndPolicyId">