JDBCTransazioneInfoService.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.core.transazioni.dao.jdbc;

  21. import org.openspcoop2.generic_project.dao.jdbc.IJDBCServiceCRUDWithoutId;

  22. import org.openspcoop2.generic_project.beans.NonNegativeNumber;
  23. import org.openspcoop2.generic_project.beans.UpdateField;
  24. import org.openspcoop2.generic_project.beans.UpdateModel;
  25. import org.openspcoop2.generic_project.dao.jdbc.JDBCProperties;
  26. import org.openspcoop2.generic_project.exception.NotFoundException;
  27. import org.openspcoop2.generic_project.exception.NotImplementedException;
  28. import org.openspcoop2.generic_project.exception.ServiceException;
  29. import org.openspcoop2.generic_project.exception.ValidationException;
  30. import org.openspcoop2.generic_project.expression.IExpression;
  31. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;

  32. import org.openspcoop2.core.transazioni.TransazioneInfo;
  33. import org.openspcoop2.core.transazioni.dao.ITransazioneInfoService;
  34. import org.openspcoop2.core.transazioni.utils.ProjectInfo;

  35. import java.sql.Connection;

  36. import org.openspcoop2.utils.sql.ISQLQueryObject;

  37. /**    
  38.  * Service can be used to search for and manage the backend objects of type {@link org.openspcoop2.core.transazioni.TransazioneInfo}
  39.  *
  40.  * @author Poli Andrea (poli@link.it)
  41.  * @author $Author$
  42.  * @version $Rev$, $Date$
  43.  */

  44. public class JDBCTransazioneInfoService extends JDBCTransazioneInfoServiceSearch  implements ITransazioneInfoService {


  45.     private IJDBCServiceCRUDWithoutId<TransazioneInfo, JDBCServiceManager> serviceCRUD = null;
  46.     public JDBCTransazioneInfoService(JDBCServiceManager jdbcServiceManager) throws ServiceException {
  47.         super(jdbcServiceManager);
  48.         String msgInit = JDBCTransazioneInfoService.class.getName()+ " initialized";
  49.         this.log.debug(msgInit);
  50.         this.serviceCRUD = JDBCProperties.getInstance(org.openspcoop2.core.transazioni.dao.jdbc.JDBCServiceManager.class.getPackage(),ProjectInfo.getInstance()).getServiceCRUD("transazioneInfo");
  51.         this.serviceCRUD.setServiceManager(new JDBCLimitedServiceManager(this.jdbcServiceManager));
  52.     }

  53.     private static final String PARAMETER_TYPE_PREFIX = "Parameter (type:";
  54.     private ServiceException newServiceExceptionParameterIsNull(){
  55.         return new ServiceException(PARAMETER_TYPE_PREFIX+TransazioneInfo.class.getName()+") 'transazioneInfo' is null");
  56.     }
  57.     private ServiceException newServiceExceptionParameterUpdateFieldsIsNull(){
  58.         return new ServiceException(PARAMETER_TYPE_PREFIX+UpdateField.class.getName()+") 'updateFields' is null");
  59.     }
  60.     private ServiceException newServiceExceptionParameterConditionIsNull(){
  61.         return new ServiceException(PARAMETER_TYPE_PREFIX+IExpression.class.getName()+") 'condition' is null");
  62.     }
  63.     private ServiceException newServiceExceptionParameterUpdateModelsIsNull(){
  64.         return new ServiceException(PARAMETER_TYPE_PREFIX+UpdateModel.class.getName()+") 'updateModels' is null");
  65.     }
  66.    
  67.     private ServiceException newServiceExceptionUpdateFieldsNotCompleted(Exception e){
  68.         return new ServiceException("UpdateFields not completed: "+e.getMessage(),e);
  69.     }
  70.    
  71.    
  72.     private void releaseResources(boolean rollback, Connection connection, boolean oldValueAutoCommit) throws ServiceException {
  73.         if(this.jdbcProperties.isAutomaticTransactionManagement()){
  74.             manageTransaction(rollback, connection);
  75.             try{
  76.                 if(connection!=null)
  77.                     connection.setAutoCommit(oldValueAutoCommit);
  78.             }catch(Exception eIgnore){
  79.                 // ignore
  80.             }
  81.         }
  82.         if(connection!=null){
  83.             this.jdbcServiceManager.closeConnection(connection);
  84.         }
  85.     }
  86.     private void manageTransaction(boolean rollback, Connection connection) {
  87.         if(rollback){
  88.             try{
  89.                 if(connection!=null)
  90.                     connection.rollback();
  91.             }catch(Exception eIgnore){
  92.                 // ignore
  93.             }
  94.         }else{
  95.             try{
  96.                 if(connection!=null)
  97.                     connection.commit();
  98.             }catch(Exception eIgnore){
  99.                 // ignore
  100.             }
  101.         }
  102.     }
  103.    
  104.    
  105.    
  106.     @Override
  107.     public void create(TransazioneInfo transazioneInfo) throws ServiceException, NotImplementedException {
  108.         try{
  109.             this.create(transazioneInfo, false, null);
  110.         }catch(ValidationException vE){
  111.             // not possible
  112.             throw new ServiceException(vE.getMessage(), vE);
  113.         }
  114.     }
  115.    
  116.     @Override
  117.     public void create(TransazioneInfo transazioneInfo, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotImplementedException {
  118.         try{
  119.             this.create(transazioneInfo, false, idMappingResolutionBehaviour);
  120.         }catch(ValidationException vE){
  121.             // not possible
  122.             throw new ServiceException(vE.getMessage(), vE);
  123.         }
  124.     }
  125.    
  126.     @Override
  127.     public void create(TransazioneInfo transazioneInfo, boolean validate) throws ServiceException, NotImplementedException, ValidationException {
  128.         this.create(transazioneInfo, validate, null);
  129.     }
  130.    
  131.     @Override
  132.     public void create(TransazioneInfo transazioneInfo, boolean validate, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotImplementedException, ValidationException {
  133.        
  134.         Connection connection = null;
  135.         boolean oldValueAutoCommit = false;
  136.         boolean rollback = false;
  137.         try{
  138.            
  139.             // check parameters
  140.             if(transazioneInfo==null){
  141.                 throw this.newServiceExceptionParameterIsNull();
  142.             }
  143.            
  144.             // validate
  145.             if(validate){
  146.                 this.validate(transazioneInfo);
  147.             }

  148.             // ISQLQueryObject
  149.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  150.             sqlQueryObject.setANDLogicOperator(true);
  151.             // Connection sql
  152.             connection = this.jdbcServiceManager.getConnection();
  153.    
  154.             // transaction
  155.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  156.                 oldValueAutoCommit = connection.getAutoCommit();
  157.                 connection.setAutoCommit(false);
  158.             }
  159.        
  160.             this.serviceCRUD.create(this.jdbcProperties,this.log,connection,sqlQueryObject,transazioneInfo,idMappingResolutionBehaviour);          

  161.         }catch(ServiceException | NotImplementedException | ValidationException e){
  162.             rollback = true;
  163.             this.logError(e); throw e;
  164.         }catch(Exception e){
  165.             rollback = true;
  166.             this.logError(e); throw new ServiceException("Create not completed: "+e.getMessage(),e);
  167.         }finally{
  168.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  169.         }

  170.     }

  171.     @Override
  172.     public void update(TransazioneInfo transazioneInfo) throws ServiceException, NotFoundException, NotImplementedException {
  173.         try{
  174.             this.update(transazioneInfo, false, null);
  175.         }catch(ValidationException vE){
  176.             // not possible
  177.             throw new ServiceException(vE.getMessage(), vE);
  178.         }
  179.     }
  180.    
  181.     @Override
  182.     public void update(TransazioneInfo transazioneInfo, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotFoundException, NotImplementedException {
  183.         try{
  184.             this.update(transazioneInfo, false, idMappingResolutionBehaviour);
  185.         }catch(ValidationException vE){
  186.             // not possible
  187.             throw new ServiceException(vE.getMessage(), vE);
  188.         }
  189.     }
  190.    
  191.     @Override
  192.     public void update(TransazioneInfo transazioneInfo, boolean validate) throws ServiceException, NotFoundException, NotImplementedException, ValidationException {
  193.         this.update(transazioneInfo, validate, null);
  194.     }
  195.        
  196.     @Override
  197.     public void update(TransazioneInfo transazioneInfo, boolean validate, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotFoundException, NotImplementedException, ValidationException {
  198.    
  199.         Connection connection = null;
  200.         boolean oldValueAutoCommit = false;
  201.         boolean rollback = false;
  202.         try{
  203.            
  204.             // check parameters
  205.             if(transazioneInfo==null){
  206.                 throw this.newServiceExceptionParameterIsNull();
  207.             }

  208.             // validate
  209.             if(validate){
  210.                 this.validate(transazioneInfo);
  211.             }

  212.             // ISQLQueryObject
  213.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  214.             sqlQueryObject.setANDLogicOperator(true);
  215.             // Connection sql
  216.             connection = this.jdbcServiceManager.getConnection();
  217.        
  218.             // transaction
  219.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  220.                 oldValueAutoCommit = connection.getAutoCommit();
  221.                 connection.setAutoCommit(false);
  222.             }

  223.             this.serviceCRUD.update(this.jdbcProperties,this.log,connection,sqlQueryObject,transazioneInfo,idMappingResolutionBehaviour);
  224.            
  225.         }catch(ServiceException | NotImplementedException | ValidationException e){
  226.             rollback = true;
  227.             this.logError(e); throw e;
  228.         }catch(NotFoundException e){
  229.             rollback = true;
  230.             this.logDebug(e); throw e;
  231.         }catch(Exception e){
  232.             rollback = true;
  233.             this.logError(e); throw new ServiceException("Update not completed: "+e.getMessage(),e);
  234.         }finally{
  235.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  236.         }

  237.     }
  238.    
  239.    
  240.     @Override
  241.     public void updateFields(TransazioneInfo transazioneInfo, UpdateField ... updateFields) throws ServiceException, NotFoundException, NotImplementedException {
  242.    
  243.         Connection connection = null;
  244.         boolean oldValueAutoCommit = false;
  245.         boolean rollback = false;
  246.         try{
  247.            
  248.             // check parameters
  249.             if(transazioneInfo==null){
  250.                 throw this.newServiceExceptionParameterIsNull();
  251.             }
  252.             if(updateFields==null){
  253.                 throw this.newServiceExceptionParameterUpdateFieldsIsNull();
  254.             }

  255.             // ISQLQueryObject
  256.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  257.             sqlQueryObject.setANDLogicOperator(true);
  258.             // Connection sql
  259.             connection = this.jdbcServiceManager.getConnection();
  260.        
  261.             // transaction
  262.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  263.                 oldValueAutoCommit = connection.getAutoCommit();
  264.                 connection.setAutoCommit(false);
  265.             }

  266.             this.serviceCRUD.updateFields(this.jdbcProperties,this.log,connection,sqlQueryObject,transazioneInfo,updateFields);
  267.            
  268.         }catch(ServiceException | NotImplementedException e){
  269.             rollback = true;
  270.             this.logError(e); throw e;
  271.         }catch(NotFoundException e){
  272.             rollback = true;
  273.             this.logDebug(e); throw e;
  274.         }catch(Exception e){
  275.             rollback = true;
  276.             this.logError(e); throw this.newServiceExceptionUpdateFieldsNotCompleted(e);
  277.         }finally{
  278.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  279.         }

  280.     }
  281.    
  282.     @Override
  283.     public void updateFields(TransazioneInfo transazioneInfo, IExpression condition, UpdateField ... updateFields) throws ServiceException, NotFoundException, NotImplementedException {
  284.    
  285.         Connection connection = null;
  286.         boolean oldValueAutoCommit = false;
  287.         boolean rollback = false;
  288.         try{
  289.            
  290.             // check parameters
  291.             if(transazioneInfo==null){
  292.                 throw this.newServiceExceptionParameterIsNull();
  293.             }
  294.             if(condition==null){
  295.                 throw this.newServiceExceptionParameterConditionIsNull();
  296.             }
  297.             if(updateFields==null){
  298.                 throw this.newServiceExceptionParameterUpdateFieldsIsNull();
  299.             }

  300.             // ISQLQueryObject
  301.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  302.             sqlQueryObject.setANDLogicOperator(true);
  303.             // Connection sql
  304.             connection = this.jdbcServiceManager.getConnection();
  305.        
  306.             // transaction
  307.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  308.                 oldValueAutoCommit = connection.getAutoCommit();
  309.                 connection.setAutoCommit(false);
  310.             }

  311.             this.serviceCRUD.updateFields(this.jdbcProperties,this.log,connection,sqlQueryObject,transazioneInfo,condition,updateFields);
  312.            
  313.         }catch(ServiceException | NotImplementedException e){
  314.             rollback = true;
  315.             this.logError(e); throw e;
  316.         }catch(NotFoundException e){
  317.             rollback = true;
  318.             this.logDebug(e); throw e;
  319.         }catch(Exception e){
  320.             rollback = true;
  321.             this.logError(e); throw this.newServiceExceptionUpdateFieldsNotCompleted(e);
  322.         }finally{
  323.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  324.         }

  325.     }

  326.     @Override
  327.     public void updateFields(TransazioneInfo transazioneInfo, UpdateModel ... updateModels) throws ServiceException, NotFoundException, NotImplementedException {
  328.    
  329.         Connection connection = null;
  330.         boolean oldValueAutoCommit = false;
  331.         boolean rollback = false;
  332.         try{
  333.            
  334.             // check parameters
  335.             if(transazioneInfo==null){
  336.                 throw this.newServiceExceptionParameterIsNull();
  337.             }
  338.             if(updateModels==null){
  339.                 throw this.newServiceExceptionParameterUpdateModelsIsNull();
  340.             }

  341.             // ISQLQueryObject
  342.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  343.             sqlQueryObject.setANDLogicOperator(true);
  344.             // Connection sql
  345.             connection = this.jdbcServiceManager.getConnection();
  346.        
  347.             // transaction
  348.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  349.                 oldValueAutoCommit = connection.getAutoCommit();
  350.                 connection.setAutoCommit(false);
  351.             }

  352.             this.serviceCRUD.updateFields(this.jdbcProperties,this.log,connection,sqlQueryObject,transazioneInfo,updateModels);
  353.            
  354.         }catch(ServiceException | NotImplementedException e){
  355.             rollback = true;
  356.             this.logError(e); throw e;
  357.         }catch(NotFoundException e){
  358.             rollback = true;
  359.             this.logDebug(e); throw e;
  360.         }catch(Exception e){
  361.             rollback = true;
  362.             this.logError(e); throw this.newServiceExceptionUpdateFieldsNotCompleted(e);
  363.         }finally{
  364.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  365.         }

  366.     }


  367.     @Override
  368.     public void updateOrCreate(TransazioneInfo transazioneInfo) throws ServiceException, NotImplementedException {
  369.         try{
  370.             this.updateOrCreate(transazioneInfo, false, null);
  371.         }catch(ValidationException vE){
  372.             // not possible
  373.             throw new ServiceException(vE.getMessage(), vE);
  374.         }
  375.     }
  376.    
  377.     @Override
  378.     public void updateOrCreate(TransazioneInfo transazioneInfo, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotImplementedException {
  379.         try{
  380.             this.updateOrCreate(transazioneInfo, false, idMappingResolutionBehaviour);
  381.         }catch(ValidationException vE){
  382.             // not possible
  383.             throw new ServiceException(vE.getMessage(), vE);
  384.         }
  385.     }

  386.     @Override
  387.     public void updateOrCreate(TransazioneInfo transazioneInfo, boolean validate) throws ServiceException, NotImplementedException, ValidationException {
  388.         this.updateOrCreate(transazioneInfo, validate, null);
  389.     }

  390.     @Override
  391.     public void updateOrCreate(TransazioneInfo transazioneInfo, boolean validate, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotImplementedException, ValidationException {
  392.    
  393.         Connection connection = null;
  394.         boolean oldValueAutoCommit = false;
  395.         boolean rollback = false;
  396.         try{
  397.            
  398.             // check parameters
  399.             if(transazioneInfo==null){
  400.                 throw this.newServiceExceptionParameterIsNull();
  401.             }

  402.             // validate
  403.             if(validate){
  404.                 this.validate(transazioneInfo);
  405.             }

  406.             // ISQLQueryObject
  407.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  408.             sqlQueryObject.setANDLogicOperator(true);
  409.             // Connection sql
  410.             connection = this.jdbcServiceManager.getConnection();
  411.        
  412.             // transaction
  413.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  414.                 oldValueAutoCommit = connection.getAutoCommit();
  415.                 connection.setAutoCommit(false);
  416.             }

  417.             this.serviceCRUD.updateOrCreate(this.jdbcProperties,this.log,connection,sqlQueryObject,transazioneInfo,idMappingResolutionBehaviour);
  418.            
  419.         }catch(ServiceException | NotImplementedException | ValidationException e){
  420.             rollback = true;
  421.             this.logError(e); throw e;
  422.         }catch(Exception e){
  423.             rollback = true;
  424.             this.logError(e); throw new ServiceException("UpdateOrCreate not completed: "+e.getMessage(),e);
  425.         }finally{
  426.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  427.         }

  428.     }
  429.    
  430.    
  431.     @Override
  432.     public void delete(TransazioneInfo transazioneInfo) throws ServiceException,NotImplementedException {
  433.        
  434.         Connection connection = null;
  435.         boolean oldValueAutoCommit = false;
  436.         boolean rollback = false;
  437.         try{
  438.            
  439.             // check parameters
  440.             if(transazioneInfo==null){
  441.                 throw this.newServiceExceptionParameterIsNull();
  442.             }

  443.             // ISQLQueryObject
  444.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  445.             sqlQueryObject.setANDLogicOperator(true);
  446.             // Connection sql
  447.             connection = this.jdbcServiceManager.getConnection();

  448.             // transaction
  449.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  450.                 oldValueAutoCommit = connection.getAutoCommit();
  451.                 connection.setAutoCommit(false);
  452.             }

  453.             this.serviceCRUD.delete(this.jdbcProperties,this.log,connection,sqlQueryObject,transazioneInfo);    

  454.         }catch(ServiceException | NotImplementedException e){
  455.             rollback = true;
  456.             this.logError(e); throw e;
  457.         }catch(Exception e){
  458.             rollback = true;
  459.             this.logError(e); throw new ServiceException("Delete not completed: "+e.getMessage(),e);
  460.         }finally{
  461.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  462.         }
  463.    
  464.     }
  465.    


  466.     @Override
  467.     public NonNegativeNumber deleteAll() throws ServiceException, NotImplementedException {

  468.         Connection connection = null;
  469.         boolean oldValueAutoCommit = false;
  470.         boolean rollback = false;
  471.         try{

  472.             // ISQLQueryObject
  473.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  474.             sqlQueryObject.setANDLogicOperator(true);
  475.             // Connection sql
  476.             connection = this.jdbcServiceManager.getConnection();
  477.        
  478.             // transaction
  479.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  480.                 oldValueAutoCommit = connection.getAutoCommit();
  481.                 connection.setAutoCommit(false);
  482.             }

  483.             return this.serviceCRUD.deleteAll(this.jdbcProperties,this.log,connection,sqlQueryObject);  

  484.         }catch(ServiceException | NotImplementedException e){
  485.             rollback = true;
  486.             this.logError(e); throw e;
  487.         }catch(Exception e){
  488.             rollback = true;
  489.             this.logError(e); throw new ServiceException("DeleteAll not completed: "+e.getMessage(),e);
  490.         }finally{
  491.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  492.         }
  493.    
  494.     }

  495.     @Override
  496.     public NonNegativeNumber deleteAll(IExpression expression) throws ServiceException, NotImplementedException {
  497.        
  498.         Connection connection = null;
  499.         boolean oldValueAutoCommit = false;
  500.         boolean rollback = false;
  501.         try{
  502.            
  503.             // check parameters
  504.             if(expression==null){
  505.                 throw this.newServiceExceptionParameterExpressionIsNull();
  506.             }
  507.             if( ! (expression instanceof JDBCExpression) ){
  508.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  509.             }
  510.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  511.             this.logJDBCExpression(jdbcExpression);
  512.        
  513.             // ISQLQueryObject
  514.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  515.             sqlQueryObject.setANDLogicOperator(true);
  516.             // Connection sql
  517.             connection = this.jdbcServiceManager.getConnection();

  518.             // transaction
  519.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  520.                 oldValueAutoCommit = connection.getAutoCommit();
  521.                 connection.setAutoCommit(false);
  522.             }

  523.             return this.serviceCRUD.deleteAll(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression);
  524.    
  525.         }catch(ServiceException | NotImplementedException e){
  526.             rollback = true;
  527.             this.logError(e); throw e;
  528.         }catch(Exception e){
  529.             rollback = true;
  530.             this.logError(e); throw new ServiceException("DeleteAll(expression) not completed: "+e.getMessage(),e);
  531.         }finally{
  532.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  533.         }
  534.    
  535.     }
  536.    
  537.    
  538.     @Override
  539.     public int nativeUpdate(String sql,Object ... param) throws ServiceException, NotImplementedException {
  540.        
  541.         Connection connection = null;
  542.         boolean oldValueAutoCommit = false;
  543.         boolean rollback = false;
  544.         try{
  545.            
  546.             // check parameters
  547.             if(sql==null){
  548.                 throw new ServiceException("Parameter 'sql' is null");
  549.             }
  550.        
  551.             // ISQLQueryObject
  552.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  553.             sqlQueryObject.setANDLogicOperator(true);
  554.             // Connection sql
  555.             connection = this.jdbcServiceManager.getConnection();

  556.             // transaction
  557.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  558.                 oldValueAutoCommit = connection.getAutoCommit();
  559.                 connection.setAutoCommit(false);
  560.             }

  561.             return this.serviceCRUD.nativeUpdate(this.jdbcProperties,this.log,connection,sqlQueryObject,sql,param);
  562.    
  563.         }catch(ServiceException | NotImplementedException e){
  564.             rollback = true;
  565.             this.logError(e); throw e;
  566.         }catch(Exception e){
  567.             rollback = true;
  568.             this.logError(e); throw new ServiceException("DeleteById(tableId) not completed: "+e.getMessage(),e);
  569.         }finally{
  570.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  571.         }
  572.    
  573.     }
  574.    
  575. }