http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientChargePaidBy.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientChargePaidBy.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientChargePaidBy.java
index de036a7..3cdfdf5 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientChargePaidBy.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientChargePaidBy.java
@@ -26,11 +26,11 @@ import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
-import org.springframework.data.jpa.domain.AbstractPersistable;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 
 @Entity
 @Table(name = "m_client_charge_paid_by")
-public class ClientChargePaidBy extends AbstractPersistable<Long> {
+public class ClientChargePaidBy extends AbstractPersistableCustom<Long> {
 
     @ManyToOne
     @JoinColumn(name = "client_transaction_id", nullable = false)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientNonPerson.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientNonPerson.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientNonPerson.java
index 541d3bb..23e18ef 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientNonPerson.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientNonPerson.java
@@ -42,11 +42,11 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
-import org.springframework.data.jpa.domain.AbstractPersistable;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 
 @Entity
 @Table(name = "m_client_non_person")
-public class ClientNonPerson extends AbstractPersistable<Long> {
+public class ClientNonPerson extends AbstractPersistableCustom<Long> {
        
        @OneToOne(optional = false)
     @JoinColumn(name = "client_id", referencedColumnName = "id", nullable = 
false, unique = true)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientNonPersonRepository.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientNonPersonRepository.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientNonPersonRepository.java
index c9723f8..d806530 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientNonPersonRepository.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientNonPersonRepository.java
@@ -25,6 +25,6 @@ import org.springframework.data.repository.query.Param;
 
 public interface ClientNonPersonRepository extends 
JpaRepository<ClientNonPerson, Long>, JpaSpecificationExecutor<ClientNonPerson>{
 
-       @Query("from ClientNonPerson clientNonPerson where 
clientNonPerson.client.id = :clientId")      
+       @Query("select clientNonPerson from ClientNonPerson clientNonPerson 
where clientNonPerson.client.id = :clientId")       
        ClientNonPerson findByClientId(@Param("clientId") Long clientId);       
 }

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransaction.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransaction.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransaction.java
index 65a0e36..c8e7266 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransaction.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransaction.java
@@ -50,11 +50,11 @@ import 
org.apache.fineract.organisation.office.domain.OrganisationCurrency;
 import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
 import org.apache.fineract.useradministration.domain.AppUser;
 import org.joda.time.LocalDate;
-import org.springframework.data.jpa.domain.AbstractPersistable;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 
 @Entity
 @Table(name = "m_client_transaction", uniqueConstraints = { 
@UniqueConstraint(columnNames = { "external_id" }, name = "external_id") })
-public class ClientTransaction extends AbstractPersistable<Long> {
+public class ClientTransaction extends AbstractPersistableCustom<Long> {
 
     @ManyToOne(optional = false)
     @JoinColumn(name = "client_id", nullable = false)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransactionRepositoryWrapper.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransactionRepositoryWrapper.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransactionRepositoryWrapper.java
index 028b5c6..3dede2f 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransactionRepositoryWrapper.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientTransactionRepositoryWrapper.java
@@ -39,7 +39,7 @@ public class ClientTransactionRepositoryWrapper {
     public ClientTransaction findOneWithNotFoundDetection(final Long clientId, 
final Long transactionId) {
         final ClientTransaction clientTransaction = 
this.repository.findOne(transactionId);
         if (clientTransaction == null
-                || clientTransaction.getClientId() != clientId) { throw new 
ClientTransactionNotFoundException(clientId, transactionId); }
+                || !clientTransaction.getClientId().equals(clientId)) { throw 
new ClientTransactionNotFoundException(clientId, transactionId); }
         // enrich Client charge with details of Organizational currency
         
clientTransaction.setCurrency(organisationCurrencyRepository.findOneWithNotFoundDetection(clientTransaction.getCurrencyCode()));
         return clientTransaction;

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientChargeWritePlatformServiceJpaRepositoryImpl.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientChargeWritePlatformServiceJpaRepositoryImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientChargeWritePlatformServiceJpaRepositoryImpl.java
index 09ee4f16..8ba8071 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientChargeWritePlatformServiceJpaRepositoryImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientChargeWritePlatformServiceJpaRepositoryImpl.java
@@ -121,8 +121,7 @@ public class 
ClientChargeWritePlatformServiceJpaRepositoryImpl implements Client
 
             final DateTimeFormatter fmt = 
DateTimeFormat.forPattern(command.dateFormat());
             validateDueDateOnWorkingDay(clientCharge, fmt);
-
-            this.clientChargeRepository.save(clientCharge);
+            this.clientChargeRepository.saveAndFlush(clientCharge);
 
             return new CommandProcessingResultBuilder() //
                     .withEntityId(clientCharge.getId()) //

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientIdentifierWritePlatformServiceJpaRepositoryImpl.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientIdentifierWritePlatformServiceJpaRepositoryImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientIdentifierWritePlatformServiceJpaRepositoryImpl.java
index ef14d63..33ec3fd 100755
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientIdentifierWritePlatformServiceJpaRepositoryImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientIdentifierWritePlatformServiceJpaRepositoryImpl.java
@@ -20,6 +20,9 @@ package org.apache.fineract.portfolio.client.service;
 
 import java.util.Map;
 
+import javax.persistence.PersistenceException;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.fineract.infrastructure.codes.domain.CodeValue;
 import 
org.apache.fineract.infrastructure.codes.domain.CodeValueRepositoryWrapper;
 import 
org.apache.fineract.infrastructure.codes.exception.CodeValueNotFoundException;
@@ -97,9 +100,12 @@ public class 
ClientIdentifierWritePlatformServiceJpaRepositoryImpl implements Cl
                     .withEntityId(clientIdentifier.getId()) //
                     .build();
         } catch (final DataIntegrityViolationException dve) {
-            handleClientIdentifierDataIntegrityViolation(documentTypeLabel, 
documentTypeId, documentKey, dve);
-            
+            handleClientIdentifierDataIntegrityViolation(documentTypeLabel, 
documentTypeId, documentKey, dve.getMostSpecificCause(), dve);
             return CommandProcessingResult.empty();
+        }catch(final PersistenceException dve) {
+               Throwable throwable = 
ExceptionUtils.getRootCause(dve.getCause()) ;
+               handleClientIdentifierDataIntegrityViolation(documentTypeLabel, 
documentTypeId, documentKey, throwable, dve);
+               return CommandProcessingResult.empty();
         }
     }
 
@@ -156,8 +162,12 @@ public class 
ClientIdentifierWritePlatformServiceJpaRepositoryImpl implements Cl
                     .with(changes) //
                     .build();
         } catch (final DataIntegrityViolationException dve) {
-            handleClientIdentifierDataIntegrityViolation(documentTypeLabel, 
documentTypeId, documentKey, dve);
+            handleClientIdentifierDataIntegrityViolation(documentTypeLabel, 
documentTypeId, documentKey, dve.getMostSpecificCause(), dve);
             return new CommandProcessingResult(Long.valueOf(-1));
+        }catch(final PersistenceException dve) {
+               Throwable throwable = 
ExceptionUtils.getRootCause(dve.getCause()) ;
+               handleClientIdentifierDataIntegrityViolation(documentTypeLabel, 
documentTypeId, documentKey, throwable, dve);
+               return CommandProcessingResult.empty();
         }
     }
 
@@ -180,11 +190,10 @@ public class 
ClientIdentifierWritePlatformServiceJpaRepositoryImpl implements Cl
     }
 
     private void handleClientIdentifierDataIntegrityViolation(final String 
documentTypeLabel, final Long documentTypeId,
-            final String documentKey, final DataIntegrityViolationException 
dve) {
-
-        if 
(dve.getMostSpecificCause().getMessage().contains("unique_active_client_identifier"))
 {
+            final String documentKey, final Throwable cause, final Exception 
dve) {
+        if (cause.getMessage().contains("unique_active_client_identifier")) {
             throw new DuplicateClientIdentifierException(documentTypeLabel);
-        } else if 
(dve.getMostSpecificCause().getMessage().contains("unique_identifier_key")) { 
throw new DuplicateClientIdentifierException(
+        } else if (cause.getMessage().contains("unique_identifier_key")) { 
throw new DuplicateClientIdentifierException(
                 documentTypeId, documentTypeLabel, documentKey); }
 
         logAsErrorUnexpectedDataIntegrityException(dve);
@@ -192,7 +201,7 @@ public class 
ClientIdentifierWritePlatformServiceJpaRepositoryImpl implements Cl
                 "Unknown data integrity issue with resource.");
     }
 
-    private void logAsErrorUnexpectedDataIntegrityException(final 
DataIntegrityViolationException dve) {
+    private void logAsErrorUnexpectedDataIntegrityException(final Exception 
dve) {
         logger.error(dve.getMessage(), dve);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
index 3e9c1c7..3c620ab 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
@@ -24,6 +24,9 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
+import javax.persistence.PersistenceException;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.fineract.commands.domain.CommandWrapper;
 import org.apache.fineract.commands.service.CommandProcessingService;
 import org.apache.fineract.commands.service.CommandWrapperBuilder;
@@ -176,9 +179,8 @@ public class ClientWritePlatformServiceJpaRepositoryImpl 
implements ClientWriteP
      * Guaranteed to throw an exception no matter what the data integrity issue
      * is.
      */
-    private void handleDataIntegrityIssues(final JsonCommand command, final 
DataIntegrityViolationException dve) {
+    private void handleDataIntegrityIssues(final JsonCommand command, final 
Throwable realCause, final Exception dve) {
 
-        final Throwable realCause = dve.getMostSpecificCause();
         if (realCause.getMessage().contains("external_id")) {
 
             final String externalId = 
command.stringValueOfParameterNamed("externalId");
@@ -316,8 +318,12 @@ public class ClientWritePlatformServiceJpaRepositoryImpl 
implements ClientWriteP
                     .setRollbackTransaction(result.isRollbackTransaction())//
                     .build();
         } catch (final DataIntegrityViolationException dve) {
-            handleDataIntegrityIssues(command, dve);
+            handleDataIntegrityIssues(command, dve.getMostSpecificCause(), 
dve);
             return CommandProcessingResult.empty();
+        }catch(final PersistenceException dve) {
+               Throwable throwable = 
ExceptionUtils.getRootCause(dve.getCause()) ;
+            handleDataIntegrityIssues(command, throwable, dve);
+               return CommandProcessingResult.empty();
         }
     }
     
@@ -500,8 +506,12 @@ public class ClientWritePlatformServiceJpaRepositoryImpl 
implements ClientWriteP
                     .with(changes) //
                     .build();
         } catch (final DataIntegrityViolationException dve) {
-            handleDataIntegrityIssues(command, dve);
+            handleDataIntegrityIssues(command, dve.getMostSpecificCause(), 
dve);
             return CommandProcessingResult.empty();
+        }catch(final PersistenceException dve) {
+               Throwable throwable = 
ExceptionUtils.getRootCause(dve.getCause()) ;
+            handleDataIntegrityIssues(command, throwable, dve);
+               return CommandProcessingResult.empty();
         }
     }
 
@@ -532,7 +542,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl 
implements ClientWriteP
                     .setRollbackTransaction(result.isRollbackTransaction())//
                     .build();
         } catch (final DataIntegrityViolationException dve) {
-            handleDataIntegrityIssues(command, dve);
+            handleDataIntegrityIssues(command, dve.getMostSpecificCause(), 
dve);
             return CommandProcessingResult.empty();
         }
     }
@@ -552,7 +562,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl 
implements ClientWriteP
         return commandProcessingResult;
     }
 
-    private void logAsErrorUnexpectedDataIntegrityException(final 
DataIntegrityViolationException dve) {
+    private void logAsErrorUnexpectedDataIntegrityException(final Exception 
dve) {
         logger.error(dve.getMessage(), dve);
     }
 
@@ -686,7 +696,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl 
implements ClientWriteP
                     .withEntityId(clientId) //
                     .build();
         } catch (final DataIntegrityViolationException dve) {
-            handleDataIntegrityIssues(command, dve);
+            handleDataIntegrityIssues(command, dve.getMostSpecificCause(), 
dve);
             return CommandProcessingResult.empty();
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/domain/LoanCollateral.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/domain/LoanCollateral.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/domain/LoanCollateral.java
index 1f787a5..6f86ef0 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/domain/LoanCollateral.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/domain/LoanCollateral.java
@@ -29,19 +29,17 @@ import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.fineract.infrastructure.codes.data.CodeValueData;
 import org.apache.fineract.infrastructure.codes.domain.CodeValue;
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import 
org.apache.fineract.portfolio.collateral.api.CollateralApiConstants.COLLATERAL_JSON_INPUT_PARAMS;
 import org.apache.fineract.portfolio.collateral.data.CollateralData;
 import org.apache.fineract.portfolio.loanaccount.domain.Loan;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 
 @Entity
 @Table(name = "m_loan_collateral")
-public class LoanCollateral extends AbstractPersistable<Long> {
+public class LoanCollateral extends AbstractPersistableCustom<Long> {
 
     @ManyToOne(optional = false)
     @JoinColumn(name = "loan_id", nullable = false)
@@ -124,7 +122,7 @@ public class LoanCollateral extends 
AbstractPersistable<Long> {
         this.type = type;
     }
 
-    @Override
+   /* @Override
     public boolean equals(final Object obj) {
         if (obj == null) { return false; }
         if (obj == this) { return true; }
@@ -146,5 +144,5 @@ public class LoanCollateral extends 
AbstractPersistable<Long> {
                 .append(this.description) //
                 .append(this.value)//
                 .toHashCode();
-    }
+    }*/
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRate.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRate.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRate.java
index 6275074..1913479 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRate.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRate.java
@@ -19,33 +19,18 @@
 package org.apache.fineract.portfolio.floatingrates.domain;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.OrderBy;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
+import java.util.*;
+
+import javax.persistence.*;
 
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper;
 import org.apache.fineract.infrastructure.core.service.DateUtils;
 import org.apache.fineract.portfolio.floatingrates.data.FloatingRateDTO;
 import org.apache.fineract.portfolio.floatingrates.data.FloatingRatePeriodData;
 import org.apache.fineract.useradministration.domain.AppUser;
 import org.joda.time.LocalDate;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
@@ -53,7 +38,7 @@ import com.google.gson.JsonObject;
 
 @Entity
 @Table(name = "m_floating_rates", uniqueConstraints = { 
@UniqueConstraint(columnNames = { "name" }, name = "unq_name") })
-public class FloatingRate extends AbstractPersistable<Long> {
+public class FloatingRate extends AbstractPersistableCustom<Long> {
 
        @Column(name = "name", length = 200, unique = true, nullable = false)
        private String name;
@@ -66,13 +51,13 @@ public class FloatingRate extends AbstractPersistable<Long> 
{
 
        @OrderBy(value = "fromDate,id")
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "floatingRate", 
orphanRemoval = true, fetch=FetchType.EAGER)
-       private Set<FloatingRatePeriod> floatingRatePeriods;
+       private List<FloatingRatePeriod> floatingRatePeriods;
 
-       @ManyToOne(optional = true)
+       @ManyToOne(optional = true, fetch=FetchType.LAZY)
        @JoinColumn(name = "createdby_id", nullable = false)
        private AppUser createdBy;
 
-       @ManyToOne(optional = true)
+       @ManyToOne(optional = true, fetch=FetchType.LAZY)
        @JoinColumn(name = "lastmodifiedby_id", nullable = false)
        private AppUser modifiedBy;
 
@@ -87,7 +72,7 @@ public class FloatingRate extends AbstractPersistable<Long> {
        }
 
        public FloatingRate(String name, boolean isBaseLendingRate,
-                       boolean isActive, Set<FloatingRatePeriod> 
floatingRatePeriods,
+                       boolean isActive, List<FloatingRatePeriod> 
floatingRatePeriods,
                        AppUser createdBy, AppUser modifiedBy, Date createdOn,
                        Date modifiedOn) {
                this.name = name;
@@ -115,7 +100,7 @@ public class FloatingRate extends AbstractPersistable<Long> 
{
                                : false;
                final boolean isActive = command.parameterExists("isActive") ? 
command
                                
.booleanPrimitiveValueOfParameterNamed("isActive") : true;
-               final Set<FloatingRatePeriod> floatingRatePeriods = 
getRatePeriods(
+               final List<FloatingRatePeriod> floatingRatePeriods = 
getRatePeriods(
                                currentUser, command);
                final LocalDate currentDate = DateUtils.getLocalDateOfTenant();
 
@@ -124,12 +109,12 @@ public class FloatingRate extends 
AbstractPersistable<Long> {
                                currentDate.toDate(), currentDate.toDate());
        }
 
-       private static Set<FloatingRatePeriod> getRatePeriods(
+       private static List<FloatingRatePeriod> getRatePeriods(
                        final AppUser currentUser, final JsonCommand command) {
                if (!command.parameterExists("ratePeriods")) {
                        return null;
                }
-               Set<FloatingRatePeriod> ratePeriods = new HashSet<>();
+               List<FloatingRatePeriod> ratePeriods = new ArrayList<>();
                JsonArray arrayOfParameterNamed = command
                                .arrayOfParameterNamed("ratePeriods");
                for (final JsonElement ratePeriod : arrayOfParameterNamed) {
@@ -165,7 +150,7 @@ public class FloatingRate extends AbstractPersistable<Long> 
{
                return this.isActive;
        }
 
-       public Set<FloatingRatePeriod> getFloatingRatePeriods() {
+       public List<FloatingRatePeriod> getFloatingRatePeriods() {
                return this.floatingRatePeriods;
        }
 
@@ -211,7 +196,7 @@ public class FloatingRate extends AbstractPersistable<Long> 
{
                        this.isActive = newValue;
                }
 
-               final Set<FloatingRatePeriod> newRatePeriods = 
getRatePeriods(appUser,
+               final List<FloatingRatePeriod> newRatePeriods = 
getRatePeriods(appUser,
                                command);
                if (newRatePeriods != null && !newRatePeriods.isEmpty()) {
                        updateRatePeriods(newRatePeriods, appUser);
@@ -223,7 +208,7 @@ public class FloatingRate extends AbstractPersistable<Long> 
{
        }
 
        private void updateRatePeriods(
-                       final Set<FloatingRatePeriod> newRatePeriods, final 
AppUser appUser) {
+                       final List<FloatingRatePeriod> newRatePeriods, final 
AppUser appUser) {
                final LocalDate today = DateUtils.getLocalDateOfTenant();
                if (this.floatingRatePeriods != null) {
                        for (FloatingRatePeriod ratePeriod : 
this.floatingRatePeriods) {

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRatePeriod.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRatePeriod.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRatePeriod.java
index d7dbb35..f9e0b45 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRatePeriod.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRatePeriod.java
@@ -23,20 +23,21 @@ import java.util.Date;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import org.apache.fineract.portfolio.floatingrates.data.FloatingRateDTO;
 import org.apache.fineract.portfolio.floatingrates.data.FloatingRatePeriodData;
 import org.apache.fineract.useradministration.domain.AppUser;
 import org.joda.time.LocalDate;
 import org.joda.time.LocalDateTime;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 
 @Entity
 @Table(name = "m_floating_rates_periods")
-public class FloatingRatePeriod extends AbstractPersistable<Long> {
+public class FloatingRatePeriod extends AbstractPersistableCustom<Long> {
 
        @ManyToOne
        @JoinColumn(name = "floating_rates_id", nullable = false)
@@ -54,11 +55,11 @@ public class FloatingRatePeriod extends 
AbstractPersistable<Long> {
        @Column(name = "is_active", nullable = false)
        private boolean isActive;
 
-       @ManyToOne(optional = true)
+       @ManyToOne(optional = true, fetch=FetchType.LAZY)
        @JoinColumn(name = "createdby_id", nullable = false)
        private AppUser createdBy;
 
-       @ManyToOne(optional = true)
+       @ManyToOne(optional = true, fetch=FetchType.LAZY)
        @JoinColumn(name = "lastmodifiedby_id", nullable = false)
        private AppUser modifiedBy;
 

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRateRepository.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRateRepository.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRateRepository.java
index af5580a..8f4b93f 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRateRepository.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/domain/FloatingRateRepository.java
@@ -28,14 +28,14 @@ public interface FloatingRateRepository extends
                JpaRepository<FloatingRate, Long>,
                JpaSpecificationExecutor<FloatingRate> {
 
-       @Query("from FloatingRate floatingRate where 
floatingRate.isBaseLendingRate = 1 and floatingRate.isActive = 1")
+       @Query("select floatingRate from FloatingRate floatingRate where 
floatingRate.isBaseLendingRate = true and floatingRate.isActive = true")
        FloatingRate retrieveBaseLendingRate();
        
-       @Query("from FloatingRate floatingRate " +
+       @Query("select floatingRate from FloatingRate floatingRate " +
                        " inner join floatingRate.floatingRatePeriods as 
periods" +
-                       " where floatingRate.isActive = 1 " +
-                       " and periods.isActive = 1 " +
-                       " and periods.isDifferentialToBaseLendingRate = 1")
+                       " where floatingRate.isActive = true " +
+                       " and periods.isActive = true " +
+                       " and periods.isDifferentialToBaseLendingRate = true")
        Collection<FloatingRate> retrieveFloatingRatesLinkedToBLR();
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/service/FloatingRateWritePlatformServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/service/FloatingRateWritePlatformServiceImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/service/FloatingRateWritePlatformServiceImpl.java
index 1e372f2..78e70cc 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/service/FloatingRateWritePlatformServiceImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/service/FloatingRateWritePlatformServiceImpl.java
@@ -20,6 +20,9 @@ package org.apache.fineract.portfolio.floatingrates.service;
 
 import java.util.Map;
 
+import javax.persistence.PersistenceException;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
 import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
 import 
org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
@@ -70,8 +73,12 @@ public class FloatingRateWritePlatformServiceImpl implements
                                        .withEntityId(newFloatingRate.getId()) 
//
                                        .build();
                } catch (final DataIntegrityViolationException dve) {
-                       handleDataIntegrityIssues(command, dve);
+                       handleDataIntegrityIssues(command, 
dve.getMostSpecificCause(), dve);
                        return CommandProcessingResult.empty();
+               }catch (final PersistenceException dve) {
+                       Throwable throwable = 
ExceptionUtils.getRootCause(dve.getCause()) ;
+            handleDataIntegrityIssues(command, throwable, dve);
+               return CommandProcessingResult.empty();
                }
        }
 
@@ -97,14 +104,17 @@ public class FloatingRateWritePlatformServiceImpl 
implements
                                        .with(changes) //
                                        .build();
                } catch (final DataIntegrityViolationException dve) {
-                       handleDataIntegrityIssues(command, dve);
+                       handleDataIntegrityIssues(command, 
dve.getMostSpecificCause(), dve);
                        return CommandProcessingResult.empty();
+               }catch (final PersistenceException dve) {
+                       Throwable throwable = 
ExceptionUtils.getRootCause(dve.getCause()) ;
+            handleDataIntegrityIssues(command, throwable, dve);
+               return CommandProcessingResult.empty();
                }
        }
 
-       private void handleDataIntegrityIssues(final JsonCommand command,
-                       final DataIntegrityViolationException dve) {
-               final Throwable realCause = dve.getMostSpecificCause();
+       private void handleDataIntegrityIssues(final JsonCommand command, final 
Throwable realCause,
+                       final Exception dve) {
 
                if (realCause.getMessage().contains("unq_name")) {
 
@@ -129,7 +139,7 @@ public class FloatingRateWritePlatformServiceImpl implements
        }
 
        private void logAsErrorUnexpectedDataIntegrityException(
-                       DataIntegrityViolationException dve) {
+                       Exception dve) {
                logger.error(dve.getMessage(), dve);
 
        }

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/domain/Fund.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/domain/Fund.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/domain/Fund.java
index aa6a579..4b748bc 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/domain/Fund.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/domain/Fund.java
@@ -28,12 +28,12 @@ import javax.persistence.UniqueConstraint;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
-import org.springframework.data.jpa.domain.AbstractPersistable;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 
 @Entity
 @Table(name = "m_fund", uniqueConstraints = { @UniqueConstraint(columnNames = 
{ "name" }, name = "fund_name_org"),
         @UniqueConstraint(columnNames = { "external_id" }, name = 
"fund_externalid_org") })
-public class Fund extends AbstractPersistable<Long> {
+public class Fund extends AbstractPersistableCustom<Long> {
 
     @Column(name = "name")
     private String name;

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java
index ef72175..f462939 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java
@@ -20,6 +20,9 @@ package org.apache.fineract.portfolio.fund.service;
 
 import java.util.Map;
 
+import javax.persistence.PersistenceException;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
 import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
 import 
org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
@@ -70,8 +73,12 @@ public class FundWritePlatformServiceJpaRepositoryImpl 
implements FundWritePlatf
 
             return new 
CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(fund.getId()).build();
         } catch (final DataIntegrityViolationException dve) {
-            handleFundDataIntegrityIssues(command, dve);
+            handleFundDataIntegrityIssues(command, dve.getMostSpecificCause(), 
dve);
             return CommandProcessingResult.empty();
+        }catch (final PersistenceException dve) {
+               Throwable throwable = 
ExceptionUtils.getRootCause(dve.getCause()) ;
+               handleFundDataIntegrityIssues(command, throwable, dve);
+               return CommandProcessingResult.empty();
         }
     }
 
@@ -95,8 +102,12 @@ public class FundWritePlatformServiceJpaRepositoryImpl 
implements FundWritePlatf
 
             return new 
CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(fund.getId()).with(changes).build();
         } catch (final DataIntegrityViolationException dve) {
-            handleFundDataIntegrityIssues(command, dve);
+            handleFundDataIntegrityIssues(command, dve.getMostSpecificCause(), 
dve);
             return CommandProcessingResult.empty();
+        }catch (final PersistenceException dve) {
+               Throwable throwable = 
ExceptionUtils.getRootCause(dve.getCause()) ;
+               handleFundDataIntegrityIssues(command, throwable, dve);
+               return CommandProcessingResult.empty();
         }
     }
 
@@ -104,9 +115,7 @@ public class FundWritePlatformServiceJpaRepositoryImpl 
implements FundWritePlatf
      * Guaranteed to throw an exception no matter what the data integrity issue
      * is.
      */
-    private void handleFundDataIntegrityIssues(final JsonCommand command, 
final DataIntegrityViolationException dve) {
-
-        final Throwable realCause = dve.getMostSpecificCause();
+    private void handleFundDataIntegrityIssues(final JsonCommand command,  
final Throwable realCause, final Exception dve) {
         if (realCause.getMessage().contains("fund_externalid_org")) {
             final String externalId = 
command.stringValueOfParameterNamed("externalId");
             throw new 
PlatformDataIntegrityException("error.msg.fund.duplicate.externalId", "A fund 
with external id '" + externalId

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/Group.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/Group.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/Group.java
index 602b071..c3a14ae 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/Group.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/Group.java
@@ -49,6 +49,7 @@ import 
org.apache.fineract.infrastructure.core.data.ApiParameterError;
 import 
org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException;
 import 
org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
 import org.apache.fineract.infrastructure.core.service.DateUtils;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import 
org.apache.fineract.infrastructure.security.service.RandomPasswordGenerator;
 import org.apache.fineract.organisation.office.domain.Office;
 import org.apache.fineract.organisation.staff.domain.Staff;
@@ -61,11 +62,10 @@ import 
org.apache.fineract.portfolio.group.exception.GroupNotExistsInCenterExcep
 import 
org.apache.fineract.portfolio.group.exception.InvalidGroupStateTransitionException;
 import org.apache.fineract.useradministration.domain.AppUser;
 import org.joda.time.LocalDate;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 
 @Entity
 @Table(name = "m_group")
-public final class Group extends AbstractPersistable<Long> {
+public final class Group extends AbstractPersistableCustom<Long> {
 
     @Column(name = "external_id", length = 100, unique = true)
     private String externalId;
@@ -122,7 +122,7 @@ public final class Group extends AbstractPersistable<Long> {
     @Temporal(TemporalType.DATE)
     private Date closureDate;
 
-    @ManyToOne(optional = true)
+    @ManyToOne(optional = true, fetch=FetchType.LAZY)
     @JoinColumn(name = "closedon_userid", nullable = true)
     private AppUser closedBy;
 
@@ -130,7 +130,7 @@ public final class Group extends AbstractPersistable<Long> {
     @Temporal(TemporalType.DATE)
     private Date submittedOnDate;
 
-    @ManyToOne(optional = true)
+    @ManyToOne(optional = true, fetch=FetchType.LAZY)
     @JoinColumn(name = "submittedon_userid", nullable = true)
     private AppUser submittedBy;
 

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/GroupLevel.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/GroupLevel.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/GroupLevel.java
index 132fc92..093460d 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/GroupLevel.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/GroupLevel.java
@@ -22,20 +22,20 @@ import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Table;
 
-import org.springframework.data.jpa.domain.AbstractPersistable;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 
 @Entity
 @Table(name = "m_group_level")
-public class GroupLevel extends AbstractPersistable<Long> {
+public class GroupLevel extends AbstractPersistableCustom<Long> {
 
     @Column(name = "parent_id")
-    private final Long parentId;
+    private Long parentId;
 
     @Column(name = "super_parent", nullable = false)
-    private final boolean superParent;
+    private boolean superParent;
 
     @Column(name = "level_name", nullable = false, length = 100, unique = true)
-    private final String levelName;
+    private String levelName;
 
     @Column(name = "recursable", nullable = false)
     private boolean recursable = false;

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/GroupRole.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/GroupRole.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/GroupRole.java
index 137c77a..d278826 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/GroupRole.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/domain/GroupRole.java
@@ -29,13 +29,13 @@ import javax.persistence.Table;
 
 import org.apache.fineract.infrastructure.codes.domain.CodeValue;
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import org.apache.fineract.portfolio.client.domain.Client;
 import org.apache.fineract.portfolio.group.api.GroupingTypesApiConstants;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 
 @Entity
 @Table(name = "m_group_roles")
-public class GroupRole extends AbstractPersistable<Long> {
+public class GroupRole extends AbstractPersistableCustom<Long> {
 
     @ManyToOne(fetch = FetchType.LAZY)
     @JoinColumn(name = "group_id")

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java
index 1aa8b5c..0cfc7f9 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java
@@ -26,6 +26,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import javax.persistence.PersistenceException;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.fineract.commands.domain.CommandWrapper;
 import org.apache.fineract.commands.service.CommandProcessingService;
 import org.apache.fineract.commands.service.CommandWrapperBuilder;
@@ -225,8 +228,12 @@ public class 
GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
                     .build();
 
         } catch (final DataIntegrityViolationException dve) {
-            handleGroupDataIntegrityIssues(command, dve, groupingType);
+            handleGroupDataIntegrityIssues(command, 
dve.getMostSpecificCause(), dve, groupingType);
             return CommandProcessingResult.empty();
+        }catch (final PersistenceException dve) {
+               Throwable throwable = 
ExceptionUtils.getRootCause(dve.getCause()) ;
+            handleGroupDataIntegrityIssues(command, throwable, dve, 
groupingType);
+               return CommandProcessingResult.empty();
         }
     }
 
@@ -300,8 +307,12 @@ public class 
GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
                     .withEntityId(groupId) //
                     .build();
         } catch (final DataIntegrityViolationException dve) {
-            handleGroupDataIntegrityIssues(command, dve, GroupTypes.GROUP);
+            handleGroupDataIntegrityIssues(command, 
dve.getMostSpecificCause(), dve, GroupTypes.GROUP);
             return CommandProcessingResult.empty();
+        }catch (final PersistenceException dve) {
+            Throwable throwable = ExceptionUtils.getRootCause(dve.getCause()) ;
+            handleGroupDataIntegrityIssues(command, throwable, dve, 
GroupTypes.GROUP);
+               return CommandProcessingResult.empty();
         }
     }
 
@@ -434,8 +445,12 @@ public class 
GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
                     .build();
 
         } catch (final DataIntegrityViolationException dve) {
-            handleGroupDataIntegrityIssues(command, dve, groupingType);
+            handleGroupDataIntegrityIssues(command, 
dve.getMostSpecificCause(), dve, groupingType);
             return CommandProcessingResult.empty();
+        }catch (final PersistenceException dve) {
+               Throwable throwable = 
ExceptionUtils.getRootCause(dve.getCause()) ;
+            handleGroupDataIntegrityIssues(command, throwable, dve, 
groupingType);
+               return CommandProcessingResult.empty();
         }
     }
 
@@ -697,7 +712,7 @@ public class 
GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
      * Guaranteed to throw an exception no matter what the data integrity issue
      * is.
      */
-    private void handleGroupDataIntegrityIssues(final JsonCommand command, 
final DataIntegrityViolationException dve,
+    private void handleGroupDataIntegrityIssues(final JsonCommand command, 
final Throwable realCause, final Exception dve,
             final GroupTypes groupLevel) {
 
         String levelName = "Invalid";
@@ -712,18 +727,17 @@ public class 
GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
             break;
         }
 
-        final Throwable realCause = dve.getMostSpecificCause();
         String errorMessageForUser = null;
         String errorMessageForMachine = null;
 
-        if (realCause.getMessage().contains("external_id")) {
+        if (realCause.getMessage().contains("'external_id'")) {
 
             final String externalId = 
command.stringValueOfParameterNamed(GroupingTypesApiConstants.externalIdParamName);
             errorMessageForUser = levelName + " with externalId `" + 
externalId + "` already exists.";
             errorMessageForMachine = "error.msg." + levelName.toLowerCase() + 
".duplicate.externalId";
             throw new PlatformDataIntegrityException(errorMessageForMachine, 
errorMessageForUser,
                     GroupingTypesApiConstants.externalIdParamName, externalId);
-        } else if (realCause.getMessage().contains("name")) {
+        } else if (realCause.getMessage().contains("'name'")) {
 
             final String name = 
command.stringValueOfParameterNamed(GroupingTypesApiConstants.nameParamName);
             errorMessageForUser = levelName + " with name `" + name + "` 
already exists.";

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestIncentives.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestIncentives.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestIncentives.java
index 094eadb..832044a 100755
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestIncentives.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestIncentives.java
@@ -29,11 +29,11 @@ import javax.persistence.Table;
 
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
 import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
-import org.springframework.data.jpa.domain.AbstractPersistable;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 
 @Entity
 @Table(name = "m_interest_incentives")
-public class InterestIncentives extends AbstractPersistable<Long> {
+public class InterestIncentives extends AbstractPersistableCustom<Long> {
 
     @ManyToOne
     @JoinColumn(name = "interest_rate_slab_id", nullable = false)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChart.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChart.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChart.java
index 3537106..8e94504 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChart.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChart.java
@@ -54,19 +54,19 @@ import 
org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConst
 import 
org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants;
 import org.apache.fineract.portfolio.savings.SavingsPeriodFrequencyType;
 import org.joda.time.LocalDate;
-import org.springframework.data.jpa.domain.AbstractPersistable;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 
 @Entity
 @Table(name = "m_interest_rate_chart")
-public class InterestRateChart extends AbstractPersistable<Long> {
+public class InterestRateChart extends AbstractPersistableCustom<Long> {
 
     @Embedded
     private InterestRateChartFields chartFields;
 
-    @OneToMany(mappedBy = "interestRateChart", cascade = CascadeType.ALL, 
orphanRemoval = true, fetch = FetchType.LAZY)
+    @OneToMany(mappedBy = "interestRateChart", cascade = CascadeType.ALL, 
orphanRemoval = true, fetch = FetchType.EAGER)
     private Set<InterestRateChartSlab> chartSlabs = new HashSet<>();
 
     protected InterestRateChart() {

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartFields.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartFields.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartFields.java
index 2b7b7a8..58af848 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartFields.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartFields.java
@@ -54,7 +54,7 @@ public class InterestRateChartFields {
     private Date fromDate;
 
     @Temporal(TemporalType.DATE)
-    @Column(name = "end_date", nullable = false)
+    @Column(name = "end_date", nullable = true)
     private Date endDate;
 
     @Column(name = "is_primary_grouping_by_amount", nullable = false)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlab.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlab.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlab.java
index 39ce24d..d1b1438 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlab.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlab.java
@@ -52,14 +52,14 @@ import 
org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
 import 
org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
 import 
org.apache.fineract.portfolio.interestratechart.InterestIncentiveApiConstants;
 import 
org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants;
-import org.springframework.data.jpa.domain.AbstractPersistable;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 
 @Entity
 @Table(name = "m_interest_rate_slab")
-public class InterestRateChartSlab extends AbstractPersistable<Long> {
+public class InterestRateChartSlab extends AbstractPersistableCustom<Long> {
 
     @Embedded
     private InterestRateChartSlabFields slabFields;
@@ -68,7 +68,7 @@ public class InterestRateChartSlab extends 
AbstractPersistable<Long> {
     @JoinColumn(name = "interest_rate_chart_id", referencedColumnName = "id", 
nullable = false)
     private InterestRateChart interestRateChart;
 
-    @OneToMany(mappedBy = "interestRateChartSlab", cascade = CascadeType.ALL, 
orphanRemoval = true, fetch = FetchType.LAZY)
+    @OneToMany(mappedBy = "interestRateChartSlab", cascade = CascadeType.ALL, 
orphanRemoval = true, fetch = FetchType.EAGER)
     private Set<InterestIncentives> interestIncentives = new HashSet<>();
 
     protected InterestRateChartSlab() {

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java
index b8c00de..8a47fb9 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java
@@ -48,7 +48,7 @@ public class InterestRateChartSlabFields {
     @Column(name = "description", nullable = true)
     private String description;
 
-    @Column(name = "period_type_enum", nullable = false)
+    @Column(name = "period_type_enum", nullable = true)
     private Integer periodType;
 
     @Column(name = "from_period")

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
index 5a43e29..c1b0f2c 100755
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
@@ -21,15 +21,44 @@ package org.apache.fineract.portfolio.loanaccount.domain;
 import java.math.BigDecimal;
 import java.math.MathContext;
 import java.math.RoundingMode;
-import java.util.*;
-
-import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.OrderBy;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import javax.persistence.UniqueConstraint;
+import javax.persistence.Version;
 
 import org.apache.commons.lang.ObjectUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.fineract.infrastructure.codes.domain.CodeValue;
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
 import org.apache.fineract.infrastructure.core.data.ApiParameterError;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import 
org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
 import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper;
 import org.apache.fineract.infrastructure.core.service.DateUtils;
@@ -73,10 +102,33 @@ import 
org.apache.fineract.portfolio.loanaccount.data.HolidayDetailDTO;
 import org.apache.fineract.portfolio.loanaccount.data.LoanTermVariationsData;
 import org.apache.fineract.portfolio.loanaccount.data.ScheduleGeneratorDTO;
 import 
org.apache.fineract.portfolio.loanaccount.domain.transactionprocessor.LoanRepaymentScheduleTransactionProcessor;
-import org.apache.fineract.portfolio.loanaccount.exception.*;
+import 
org.apache.fineract.portfolio.loanaccount.exception.ExceedingTrancheCountException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.InvalidLoanStateTransitionException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.InvalidLoanTransactionTypeException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.InvalidRefundDateException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.LoanApplicationDateException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.LoanDisbursalException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.LoanForeclosureException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.LoanOfficerAssignmentDateException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.LoanOfficerAssignmentException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.LoanOfficerUnassignmentDateException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.MultiDisbursementDataRequiredException;
+import 
org.apache.fineract.portfolio.loanaccount.exception.UndoLastTrancheDisbursementException;
 import 
org.apache.fineract.portfolio.loanaccount.loanschedule.data.LoanScheduleDTO;
-import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.*;
-import org.apache.fineract.portfolio.loanproduct.domain.*;
+import 
org.apache.fineract.portfolio.loanaccount.loanschedule.domain.AprCalculator;
+import 
org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanApplicationTerms;
+import 
org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleGenerator;
+import 
org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleModel;
+import 
org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleModelPeriod;
+import org.apache.fineract.portfolio.loanproduct.domain.AmortizationMethod;
+import 
org.apache.fineract.portfolio.loanproduct.domain.InterestCalculationPeriodMethod;
+import org.apache.fineract.portfolio.loanproduct.domain.InterestMethod;
+import 
org.apache.fineract.portfolio.loanproduct.domain.InterestRecalculationCompoundingMethod;
+import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
+import 
org.apache.fineract.portfolio.loanproduct.domain.LoanProductRelatedDetail;
+import 
org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMethod;
+import 
org.apache.fineract.portfolio.loanproduct.domain.LoanTransactionProcessingStrategy;
+import 
org.apache.fineract.portfolio.loanproduct.domain.RecalculationFrequencyType;
 import org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations;
 import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
 import org.apache.fineract.useradministration.domain.AppUser;
@@ -85,7 +137,6 @@ import org.joda.time.LocalDate;
 import org.joda.time.LocalDateTime;
 import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 import org.springframework.stereotype.Component;
 
 import com.google.gson.JsonArray;
@@ -97,7 +148,7 @@ import com.google.gson.JsonPrimitive;
 @Component
 @Table(name = "m_loan", uniqueConstraints = { @UniqueConstraint(columnNames = 
{ "account_no" }, name = "loan_account_no_UNIQUE"),
         @UniqueConstraint(columnNames = { "external_id" }, name = 
"loan_externalid_UNIQUE") })
-public class Loan extends AbstractPersistable<Long> {
+public class Loan extends AbstractPersistableCustom<Long> {
 
     /** Disable optimistic locking till batch jobs failures can be fixed **/
     @Version
@@ -259,11 +310,11 @@ public class Loan extends AbstractPersistable<Long> {
 
     @OrderBy(value = "installmentNumber")
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = 
true, fetch=FetchType.LAZY)
-    private final List<LoanRepaymentScheduleInstallment> 
repaymentScheduleInstallments = new ArrayList<>();
+    private List<LoanRepaymentScheduleInstallment> 
repaymentScheduleInstallments = new ArrayList<>();
 
     @OrderBy(value = "dateOf, id")
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = 
true, fetch=FetchType.LAZY)
-    private final List<LoanTransaction> loanTransactions = new ArrayList<>();
+    private List<LoanTransaction> loanTransactions = new ArrayList<>();
 
     @Embedded
     private LoanSummary summary;
@@ -287,7 +338,7 @@ public class Loan extends AbstractPersistable<Long> {
     @Column(name = "fixed_emi_amount", scale = 6, precision = 19, nullable = 
true)
     private BigDecimal fixedEmiAmount;
 
-    @Column(name = "max_outstanding_loan_balance", scale = 6, precision = 19, 
nullable = false)
+    @Column(name = "max_outstanding_loan_balance", scale = 6, precision = 19, 
nullable = true)
     private BigDecimal maxOutstandingLoanBalance;
 
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = 
true, fetch=FetchType.LAZY)
@@ -296,7 +347,7 @@ public class Loan extends AbstractPersistable<Long> {
 
     @OrderBy(value = "termApplicableFrom, id")
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = 
true, fetch=FetchType.LAZY)
-    private final List<LoanTermVariations> loanTermVariations = new 
ArrayList<>();
+    private List<LoanTermVariations> loanTermVariations = new ArrayList<>();
 
     @Column(name = "total_recovered_derived", scale = 6, precision = 19)
     private BigDecimal totalRecovered;

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java
index 0189ee4..05de5fa 100755
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java
@@ -41,8 +41,8 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
-import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.fineract.infrastructure.core.api.JsonCommand;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
 import org.apache.fineract.organisation.monetary.domain.Money;
 import org.apache.fineract.organisation.monetary.domain.MoneyHelper;
@@ -54,11 +54,10 @@ import 
org.apache.fineract.portfolio.charge.exception.LoanChargeWithoutMandatory
 import org.apache.fineract.portfolio.loanaccount.command.LoanChargeCommand;
 import org.apache.fineract.portfolio.loanaccount.data.LoanChargePaidDetail;
 import org.joda.time.LocalDate;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 
 @Entity
 @Table(name = "m_loan_charge")
-public class LoanCharge extends AbstractPersistable<Long> {
+public class LoanCharge extends AbstractPersistableCustom<Long> {
 
     @ManyToOne(optional = false)
     @JoinColumn(name = "loan_id", referencedColumnName = "id", nullable = 
false)
@@ -121,15 +120,15 @@ public class LoanCharge extends AbstractPersistable<Long> 
{
     private BigDecimal maxCap;
 
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "loancharge", 
orphanRemoval = true, fetch=FetchType.EAGER)
-    private final Set<LoanInstallmentCharge> loanInstallmentCharge = new 
HashSet<>();
+    private Set<LoanInstallmentCharge> loanInstallmentCharge = new HashSet<>();
 
     @Column(name = "is_active", nullable = false)
     private boolean active = true;
 
-    @OneToOne(mappedBy = "loancharge", cascade = CascadeType.ALL, optional = 
true, orphanRemoval = true, fetch = FetchType.LAZY)
+    @OneToOne(mappedBy = "loancharge", cascade = CascadeType.ALL, optional = 
true, orphanRemoval = true, fetch = FetchType.EAGER)
     private LoanOverdueInstallmentCharge overdueInstallmentCharge;
 
-    @OneToOne(mappedBy = "loancharge", cascade = CascadeType.ALL, optional = 
true, orphanRemoval = true, fetch = FetchType.LAZY)
+    @OneToOne(mappedBy = "loancharge", cascade = CascadeType.ALL, optional = 
true, orphanRemoval = true, fetch = FetchType.EAGER)
     private LoanTrancheDisbursementCharge loanTrancheDisbursementCharge;
 
     public static LoanCharge createNewFromJson(final Loan loan, final Charge 
chargeDefinition, final JsonCommand command) {
@@ -500,7 +499,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
             for (final LoanInstallmentCharge chargePerInstallment : 
this.loanInstallmentCharge) {
                 if (index == loanChargePerInstallmentArray.length) {
                     remove.add(chargePerInstallment);
-                    chargePerInstallment.updateInstallment(null);
+                    //chargePerInstallment.updateInstallment(null);
                 } else {
                     
chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]);
                 }
@@ -757,7 +756,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
         return this.charge;
     }
 
-    @Override
+    /*@Override
     public boolean equals(final Object obj) {
         if (obj == null) { return false; }
         if (obj == this) { return true; }
@@ -774,12 +773,12 @@ public class LoanCharge extends AbstractPersistable<Long> 
{
     @Override
     public int hashCode() {
         return 1;
-        /*
+        
          * return new HashCodeBuilder(3, 5) // .append(getId()) //
          * .append(this.charge.getId()) //
          * .append(this.amount).append(getDueLocalDate()) // .toHashCode();
-         */
-    }
+         
+    }*/
 
     public ChargePaymentMode getChargePaymentMode() {
         return ChargePaymentMode.fromInt(this.chargePaymentMode);

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanChargePaidBy.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanChargePaidBy.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanChargePaidBy.java
index c2fbfef..9328e9e 100755
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanChargePaidBy.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanChargePaidBy.java
@@ -27,11 +27,11 @@ import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
-import org.springframework.data.jpa.domain.AbstractPersistable;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 
 @Entity
 @Table(name = "m_loan_charge_paid_by")
-public class LoanChargePaidBy extends AbstractPersistable<Long> {
+public class LoanChargePaidBy extends AbstractPersistableCustom<Long> {
 
     @ManyToOne
     @JoinColumn(name = "loan_transaction_id", nullable = false)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
index 0fba38a..ef70a18 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
@@ -29,13 +29,13 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import org.apache.fineract.portfolio.loanaccount.data.DisbursementData;
 import org.joda.time.LocalDate;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 
 @Entity
 @Table(name = "m_loan_disbursement_detail")
-public class LoanDisbursementDetails extends AbstractPersistable<Long> {
+public class LoanDisbursementDetails extends AbstractPersistableCustom<Long> {
 
     @ManyToOne
     @JoinColumn(name = "loan_id", nullable = false)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInstallmentCharge.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInstallmentCharge.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInstallmentCharge.java
index f1f8c4e..22e23f5 100755
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInstallmentCharge.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInstallmentCharge.java
@@ -26,13 +26,13 @@ import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
 import org.apache.fineract.organisation.monetary.domain.Money;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 
 @Entity
 @Table(name = "m_loan_installment_charge")
-public class LoanInstallmentCharge extends AbstractPersistable<Long> {
+public class LoanInstallmentCharge extends AbstractPersistableCustom<Long> {
 
     @ManyToOne(optional = false)
     @JoinColumn(name = "loan_charge_id", referencedColumnName = "id", nullable 
= false)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalcualtionAdditionalDetails.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalcualtionAdditionalDetails.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalcualtionAdditionalDetails.java
index f374760..246af1e 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalcualtionAdditionalDetails.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalcualtionAdditionalDetails.java
@@ -27,12 +27,12 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import org.joda.time.LocalDate;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 
 @Entity
 @Table(name = "m_loan_interest_recalculation_additional_details")
-public class LoanInterestRecalcualtionAdditionalDetails extends 
AbstractPersistable<Long> {
+public class LoanInterestRecalcualtionAdditionalDetails extends 
AbstractPersistableCustom<Long> {
 
     @Temporal(TemporalType.DATE)
     @Column(name = "effective_date")

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java
index a56c004..b5757d5 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java
@@ -24,11 +24,11 @@ import javax.persistence.JoinColumn;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
 
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 import 
org.apache.fineract.portfolio.loanproduct.domain.InterestRecalculationCompoundingMethod;
 import 
org.apache.fineract.portfolio.loanproduct.domain.LoanProductInterestRecalculationDetails;
 import 
org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMethod;
 import 
org.apache.fineract.portfolio.loanproduct.domain.RecalculationFrequencyType;
-import org.springframework.data.jpa.domain.AbstractPersistable;
 
 /**
  * Entity for holding interest recalculation setting, details will be copied
@@ -39,7 +39,7 @@ import 
org.springframework.data.jpa.domain.AbstractPersistable;
 
 @Entity
 @Table(name = "m_loan_recalculation_details")
-public class LoanInterestRecalculationDetails extends 
AbstractPersistable<Long> {
+public class LoanInterestRecalculationDetails extends 
AbstractPersistableCustom<Long> {
 
     @OneToOne
     @JoinColumn(name = "loan_id", nullable = false)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanOverdueInstallmentCharge.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanOverdueInstallmentCharge.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanOverdueInstallmentCharge.java
index e1a9326..7385489 100755
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanOverdueInstallmentCharge.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanOverdueInstallmentCharge.java
@@ -24,11 +24,11 @@ import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
-import org.springframework.data.jpa.domain.AbstractPersistable;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
 
 @Entity
 @Table(name = "m_loan_overdue_installment_charge")
-public class LoanOverdueInstallmentCharge extends AbstractPersistable<Long> {
+public class LoanOverdueInstallmentCharge extends 
AbstractPersistableCustom<Long> {
 
     @ManyToOne(optional = false)
     @JoinColumn(name = "loan_charge_id", referencedColumnName = "id", nullable 
= false)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
index c31d1ec..81eff34 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
@@ -46,7 +46,7 @@ import org.joda.time.LocalDate;
 public final class LoanRepaymentScheduleInstallment extends 
AbstractAuditableCustom<AppUser, Long> {
 
     @ManyToOne(optional = false)
-    @JoinColumn(name = "loan_id")
+    @JoinColumn(name = "loan_id", referencedColumnName="id")
     private Loan loan;
 
     @Column(name = "installment", nullable = false)
@@ -133,6 +133,7 @@ public final class LoanRepaymentScheduleInstallment extends 
AbstractAuditableCus
     @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, 
fetch=FetchType.EAGER)
     @JoinColumn(name = "loan_repayment_schedule_id", referencedColumnName = 
"id", nullable = false)
     private Set<LoanInterestRecalcualtionAdditionalDetails> 
loanCompoundingDetails = new HashSet<>();
+    
     protected LoanRepaymentScheduleInstallment() {
         this.installmentNumber = null;
         this.fromDate = null;

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java
index 9292ace..fe17368 100755
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java
@@ -29,10 +29,10 @@ import org.springframework.data.repository.query.Param;
 
 public interface LoanRepository extends JpaRepository<Loan, Long>, 
JpaSpecificationExecutor<Loan> {
 
-    public static final String FIND_GROUP_LOANS_DISBURSED_AFTER = "from Loan l 
where l.actualDisbursementDate > :disbursementDate and "
+    public static final String FIND_GROUP_LOANS_DISBURSED_AFTER = "select l 
from Loan l where l.actualDisbursementDate > :disbursementDate and "
             + "l.group.id = :groupId and l.loanType = :loanType order by 
l.actualDisbursementDate";
 
-    public static final String FIND_CLIENT_OR_JLG_LOANS_DISBURSED_AFTER = 
"from Loan l where l.actualDisbursementDate > :disbursementDate and "
+    public static final String FIND_CLIENT_OR_JLG_LOANS_DISBURSED_AFTER = 
"select l from Loan l where l.actualDisbursementDate > :disbursementDate and "
             + "l.client.id = :clientId order by l.actualDisbursementDate";
 
     public static final String FIND_MAX_GROUP_LOAN_COUNTER_QUERY = "Select 
MAX(l.loanCounter) from Loan l where l.group.id = :groupId "
@@ -47,16 +47,16 @@ public interface LoanRepository extends JpaRepository<Loan, 
Long>, JpaSpecificat
     public static final String 
FIND_MAX_CLIENT_OR_JLG_LOAN_PRODUCT_COUNTER_QUERY = "Select 
MAX(l.loanProductCounter) from Loan l where "
             + "l.client.id = :clientId and l.loanProduct.id = :productId";
 
-    public static final String FIND_GROUP_LOANS_TO_UPDATE = "from Loan l where 
l.loanCounter > :loanCounter and "
+    public static final String FIND_GROUP_LOANS_TO_UPDATE = "select l from 
Loan l where l.loanCounter > :loanCounter and "
             + "l.group.id = :groupId and l.loanType = :groupLoanType order by 
l.loanCounter";
 
-    public static final String FIND_CLIENT_OR_JLG_LOANS_TO_UPDATE = "from Loan 
l where l.loanCounter > :loanCounter and "
+    public static final String FIND_CLIENT_OR_JLG_LOANS_TO_UPDATE = "select l 
from Loan l where l.loanCounter > :loanCounter and "
             + "l.client.id = :clientId order by l.loanCounter";
 
-    public static final String FIND_GROUP_LOANS_TO_UPDATE_LOANPRODUCT_COUNTER 
= "from Loan l where l.loanProductCounter > :loanProductCounter"
+    public static final String FIND_GROUP_LOANS_TO_UPDATE_LOANPRODUCT_COUNTER 
= "select l from Loan l where l.loanProductCounter > :loanProductCounter"
             + " and l.group.id = :groupId and l.loanType = :groupLoanType and 
l.loanCounter is NULL order by l.loanProductCounter";
 
-    public static final String FIND_CLIENT_LOANS_TO_UPDATE_LOANPRODUCT_COUNTER 
= "from Loan l where l.loanProductCounter > :loanProductCounter"
+    public static final String FIND_CLIENT_LOANS_TO_UPDATE_LOANPRODUCT_COUNTER 
= "select l from Loan l where l.loanProductCounter > :loanProductCounter"
             + " and l.client.id = :clientId and l.loanCounter is NULL order by 
l.loanProductCounter";
 
     public static final String FIND_ACTIVE_LOANS_PRODUCT_IDS_BY_CLIENT = 
"Select loan.loanProduct.id from Loan loan where "
@@ -65,13 +65,13 @@ public interface LoanRepository extends JpaRepository<Loan, 
Long>, JpaSpecificat
     public static final String FIND_ACTIVE_LOANS_PRODUCT_IDS_BY_GROUP = 
"Select loan.loanProduct.id from Loan loan where "
             + "loan.group.id = :groupId and loan.loanStatus = :loanStatus and 
loan.client.id is NULL group by loan.loanProduct.id";
 
-    public static final String DOES_CLIENT_HAVE_NON_CLOSED_LOANS = "select 
case when (count (loan) > 0) then true else false end from Loan loan where 
loan.client.id = :clientId and loan.loanStatus in (100,200,300,303,304,700)";
+    public static final String DOES_CLIENT_HAVE_NON_CLOSED_LOANS = "select 
case when (count (loan) > 0) then 'true' else 'false' end from Loan loan where 
loan.client.id = :clientId and loan.loanStatus in (100,200,300,303,304,700)";
 
-    public static final String DOES_PRODUCT_HAVE_NON_CLOSED_LOANS = "select 
case when (count (loan) > 0) then true else false end from Loan loan where 
loan.loanProduct.id = :productId and loan.loanStatus in 
(100,200,300,303,304,700)";
+    public static final String DOES_PRODUCT_HAVE_NON_CLOSED_LOANS = "select 
case when (count (loan) > 0) then 'true' else 'false' end from Loan loan where 
loan.loanProduct.id = :productId and loan.loanStatus in 
(100,200,300,303,304,700)";
 
-    public static final String FIND_BY_ACCOUNT_NUMBER = "from Loan loan where 
loan.accountNumber = :accountNumber and loan.loanStatus in 
(100,200,300,303,304)";
+    public static final String FIND_BY_ACCOUNT_NUMBER = "select loan from Loan 
loan where loan.accountNumber = :accountNumber and loan.loanStatus in 
(100,200,300,303,304)";
 
-    public static final String FIND_NON_CLOSED_LOAN_THAT_BELONGS_TO_CLIENT = 
"from Loan loan where loan.id = :loanId and loan.loanStatus = 300 and 
loan.client.id = :clientId";
+    public static final String FIND_NON_CLOSED_LOAN_THAT_BELONGS_TO_CLIENT = 
"select loan from Loan loan where loan.id = :loanId and loan.loanStatus = 300 
and loan.client.id = :clientId";
 
     @Query(FIND_GROUP_LOANS_DISBURSED_AFTER)
     List<Loan> getGroupLoansDisbursedAfter(@Param("disbursementDate") Date 
disbursementDate, @Param("groupId") Long groupId,
@@ -108,31 +108,31 @@ public interface LoanRepository extends 
JpaRepository<Loan, Long>, JpaSpecificat
     List<Loan> 
getClientLoansToUpdateLoanProductCounter(@Param("loanProductCounter") Integer 
loanProductCounter,
             @Param("clientId") Long clientId);
 
-    @Query("from Loan loan where loan.client.id = :clientId and loan.group.id 
= :groupId")
+    @Query("select loan from Loan loan where loan.client.id = :clientId and 
loan.group.id = :groupId")
     List<Loan> findByClientIdAndGroupId(@Param("clientId") Long clientId, 
@Param("groupId") Long groupId);
 
-    @Query("from Loan loan where loan.client.id = :clientId and loan.group.id 
= :groupId and loan.loanStatus IN :loanStatuses")
+    @Query("select loan from Loan loan where loan.client.id = :clientId and 
loan.group.id = :groupId and loan.loanStatus IN :loanStatuses")
     List<Loan> findByClientIdAndGroupIdAndLoanStatus(@Param("clientId") Long 
clientId, @Param("groupId") Long groupId,
             @Param("loanStatuses") Collection<Integer> loanStatuses);
 
-    @Query("from Loan loan where loan.client.id = :clientId")
+    @Query("select loan from Loan loan where loan.client.id = :clientId")
     List<Loan> findLoanByClientId(@Param("clientId") Long clientId);
 
-    @Query("from Loan loan where loan.group.id = :groupId and loan.client.id 
is null")
+    @Query("select loan from Loan loan where loan.group.id = :groupId and 
loan.client.id is null")
     List<Loan> findByGroupId(@Param("groupId") Long groupId);
 
-    @Query("from Loan loan where loan.id IN :ids and loan.loanStatus IN 
:loanStatuses and loan.loanType IN :loanTypes")
+    @Query("select loan from Loan loan where loan.id IN :ids and 
loan.loanStatus IN :loanStatuses and loan.loanType IN :loanTypes")
     List<Loan> findByIdsAndLoanStatusAndLoanType(@Param("ids") 
Collection<Long> ids,
             @Param("loanStatuses") Collection<Integer> loanStatuses, 
@Param("loanTypes") Collection<Integer> loanTypes);
 
     @Query("select loan.id from Loan loan where loan.actualDisbursementDate > 
:disbursalDate order by loan.actualDisbursementDate")
     List<Long> getLoansDisbursedAfter(@Param("disbursalDate") Date 
disbursalDate);
 
-    @Query("from Loan loan where loan.client.office.id IN :officeIds and 
loan.loanStatus IN :loanStatuses")
+    @Query("select loan from Loan loan where loan.client.office.id IN 
:officeIds and loan.loanStatus IN :loanStatuses")
     List<Loan> findByClientOfficeIdsAndLoanStatus(@Param("officeIds") 
Collection<Long> officeIds,
             @Param("loanStatuses") Collection<Integer> loanStatuses);
 
-    @Query("from Loan loan where loan.group.office.id IN :officeIds and 
loan.loanStatus IN :loanStatuses")
+    @Query("select loan from Loan loan where loan.group.office.id IN 
:officeIds and loan.loanStatus IN :loanStatuses")
     List<Loan> findByGroupOfficeIdsAndLoanStatus(@Param("officeIds") 
Collection<Long> officeIds,
             @Param("loanStatuses") Collection<Integer> loanStatuses);
 

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/9d7f1c21/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java
index 9a32523..c692bb3 100755
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java
@@ -72,6 +72,7 @@ public class LoanRepositoryWrapper {
         return this.repository.saveAndFlush(loan) ;
     }
     
+    @Transactional
     public Loan save(final Loan loan) {
         return this.repository.save(loan) ;
     }


Reply via email to