Refactor to provide Common Policy Validation
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / daoimpl / CommonClassDaoImpl.java
index 5d2b7f6..c714821 100644 (file)
@@ -44,9 +44,12 @@ import org.onap.policy.rest.jpa.GroupPolicyScopeList;
 import org.onap.policy.rest.jpa.PolicyRoles;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 
 @Service("CommonClassDao")
+@Primary
 public class CommonClassDaoImpl implements CommonClassDao{
 
        private static final Log LOGGER = LogFactory.getLog(CommonClassDaoImpl.class);
@@ -54,6 +57,7 @@ public class CommonClassDaoImpl implements CommonClassDao{
        
        private static SessionFactory sessionFactory;
        
+       
        @Autowired
        private CommonClassDaoImpl(SessionFactory sessionFactory){
                CommonClassDaoImpl.sessionFactory = sessionFactory;
@@ -242,7 +246,12 @@ public class CommonClassDaoImpl implements CommonClassDao{
                try {
                        Query hbquery = session.createQuery(query);
                        for (Map.Entry<String, Object> paramPair : params.entrySet()) {
-                               hbquery.setParameter(paramPair.getKey(), paramPair.getValue());
+                               if(paramPair.getValue() instanceof java.lang.Long){
+                                       hbquery.setLong(paramPair.getKey(), (long) paramPair.getValue());
+                               }
+                               else{
+                                       hbquery.setParameter(paramPair.getKey(), paramPair.getValue());
+                               }
                        }
                        data = hbquery.list();
                        tx.commit();