JDBCConfigurazioneGeneraleService.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.controllo_traffico.dao.jdbc;

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

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

  30. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  31. import org.openspcoop2.core.controllo_traffico.dao.IDBConfigurazioneGeneraleService;
  32. import org.openspcoop2.core.controllo_traffico.utils.ProjectInfo;

  33. import java.sql.Connection;

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

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

  42. public class JDBCConfigurazioneGeneraleService extends JDBCConfigurazioneGeneraleServiceSearch  implements IDBConfigurazioneGeneraleService {


  43.     private IJDBCServiceCRUDSingleObject<ConfigurazioneGenerale, JDBCServiceManager> serviceCRUD = null;
  44.     public JDBCConfigurazioneGeneraleService(JDBCServiceManager jdbcServiceManager) throws ServiceException {
  45.         super(jdbcServiceManager);
  46.         String msgInit = JDBCConfigurazioneGeneraleService.class.getName()+ " initialized";
  47.         this.log.debug(msgInit);
  48.         this.serviceCRUD = JDBCProperties.getInstance(org.openspcoop2.core.controllo_traffico.dao.jdbc.JDBCServiceManager.class.getPackage(),ProjectInfo.getInstance()).getServiceCRUD("configurazioneGenerale");
  49.         this.serviceCRUD.setServiceManager(new JDBCLimitedServiceManager(this.jdbcServiceManager));
  50.     }

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

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

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

  168.     }

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

  206.             // validate
  207.             if(validate){
  208.                 this.validate(configurazioneGenerale);
  209.             }

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

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

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

  250.             // ISQLQueryObject
  251.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  252.             sqlQueryObject.setANDLogicOperator(true);
  253.             // Connection sql
  254.             connection = this.jdbcServiceManager.getConnection();
  255.        
  256.             // transaction
  257.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  258.                 oldValueAutoCommit = connection.getAutoCommit();
  259.                 connection.setAutoCommit(false);
  260.             }

  261.             this.serviceCRUD.updateFields(this.jdbcProperties,this.log,connection,sqlQueryObject,updateFields);
  262.            
  263.         }catch(ServiceException | NotImplementedException e){
  264.             rollback = true;
  265.             this.logError(e); throw e;
  266.         }catch(NotFoundException e){
  267.             rollback = true;
  268.             this.logDebug(e); throw e;
  269.         }catch(Exception e){
  270.             rollback = true;
  271.             this.logError(e); throw this.newServiceExceptionUpdateFieldsNotCompleted(e);
  272.         }finally{
  273.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  274.         }

  275.     }
  276.    
  277.     @Override
  278.     public void updateFields(IExpression condition, UpdateField ... updateFields) throws ServiceException, NotFoundException, NotImplementedException {
  279.    
  280.         Connection connection = null;
  281.         boolean oldValueAutoCommit = false;
  282.         boolean rollback = false;
  283.         try{
  284.            
  285.             // check parameters
  286.             if(condition==null){
  287.                 throw this.newServiceExceptionParameterConditionIsNull();
  288.             }
  289.             if(updateFields==null){
  290.                 throw this.newServiceExceptionParameterUpdateFieldsIsNull();
  291.             }

  292.             // ISQLQueryObject
  293.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  294.             sqlQueryObject.setANDLogicOperator(true);
  295.             // Connection sql
  296.             connection = this.jdbcServiceManager.getConnection();
  297.        
  298.             // transaction
  299.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  300.                 oldValueAutoCommit = connection.getAutoCommit();
  301.                 connection.setAutoCommit(false);
  302.             }

  303.             this.serviceCRUD.updateFields(this.jdbcProperties,this.log,connection,sqlQueryObject,condition,updateFields);
  304.            
  305.         }catch(ServiceException | NotImplementedException e){
  306.             rollback = true;
  307.             this.logError(e); throw e;
  308.         }catch(NotFoundException e){
  309.             rollback = true;
  310.             this.logDebug(e); throw e;
  311.         }catch(Exception e){
  312.             rollback = true;
  313.             this.logError(e); throw this.newServiceExceptionUpdateFieldsNotCompleted(e);
  314.         }finally{
  315.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  316.         }

  317.     }

  318.     @Override
  319.     public void updateFields(UpdateModel ... updateModels) throws ServiceException, NotFoundException, NotImplementedException {
  320.    
  321.         Connection connection = null;
  322.         boolean oldValueAutoCommit = false;
  323.         boolean rollback = false;
  324.         try{
  325.            
  326.             // check parameters
  327.             if(updateModels==null){
  328.                 throw this.newServiceExceptionParameterUpdateModelsIsNull();
  329.             }

  330.             // ISQLQueryObject
  331.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  332.             sqlQueryObject.setANDLogicOperator(true);
  333.             // Connection sql
  334.             connection = this.jdbcServiceManager.getConnection();
  335.        
  336.             // transaction
  337.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  338.                 oldValueAutoCommit = connection.getAutoCommit();
  339.                 connection.setAutoCommit(false);
  340.             }

  341.             this.serviceCRUD.updateFields(this.jdbcProperties,this.log,connection,sqlQueryObject,updateModels);
  342.            
  343.         }catch(ServiceException | NotImplementedException e){
  344.             rollback = true;
  345.             this.logError(e); throw e;
  346.         }catch(NotFoundException e){
  347.             rollback = true;
  348.             this.logDebug(e); throw e;
  349.         }catch(Exception e){
  350.             rollback = true;
  351.             this.logError(e); throw this.newServiceExceptionUpdateFieldsNotCompleted(e);
  352.         }finally{
  353.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  354.         }

  355.     }


  356.     @Override
  357.     public void updateOrCreate(ConfigurazioneGenerale configurazioneGenerale) throws ServiceException, NotImplementedException {
  358.         try{
  359.             this.updateOrCreate(configurazioneGenerale, false, null);
  360.         }catch(ValidationException vE){
  361.             // not possible
  362.             throw new ServiceException(vE.getMessage(), vE);
  363.         }
  364.     }
  365.    
  366.     @Override
  367.     public void updateOrCreate(ConfigurazioneGenerale configurazioneGenerale, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotImplementedException {
  368.         try{
  369.             this.updateOrCreate(configurazioneGenerale, false, idMappingResolutionBehaviour);
  370.         }catch(ValidationException vE){
  371.             // not possible
  372.             throw new ServiceException(vE.getMessage(), vE);
  373.         }
  374.     }

  375.     @Override
  376.     public void updateOrCreate(ConfigurazioneGenerale configurazioneGenerale, boolean validate) throws ServiceException, NotImplementedException, ValidationException {
  377.         this.updateOrCreate(configurazioneGenerale, validate, null);
  378.     }

  379.     @Override
  380.     public void updateOrCreate(ConfigurazioneGenerale configurazioneGenerale, boolean validate, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotImplementedException, ValidationException {
  381.    
  382.         Connection connection = null;
  383.         boolean oldValueAutoCommit = false;
  384.         boolean rollback = false;
  385.         try{
  386.            
  387.             // check parameters
  388.             if(configurazioneGenerale==null){
  389.                 throw this.newServiceExceptionParameterIsNull();
  390.             }

  391.             // validate
  392.             if(validate){
  393.                 this.validate(configurazioneGenerale);
  394.             }

  395.             // ISQLQueryObject
  396.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  397.             sqlQueryObject.setANDLogicOperator(true);
  398.             // Connection sql
  399.             connection = this.jdbcServiceManager.getConnection();
  400.        
  401.             // transaction
  402.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  403.                 oldValueAutoCommit = connection.getAutoCommit();
  404.                 connection.setAutoCommit(false);
  405.             }

  406.             this.serviceCRUD.updateOrCreate(this.jdbcProperties,this.log,connection,sqlQueryObject,configurazioneGenerale,idMappingResolutionBehaviour);
  407.            
  408.         }catch(ServiceException | NotImplementedException | ValidationException e){
  409.             rollback = true;
  410.             this.logError(e); throw e;
  411.         }catch(Exception e){
  412.             rollback = true;
  413.             this.logError(e); throw new ServiceException("UpdateOrCreate not completed: "+e.getMessage(),e);
  414.         }finally{
  415.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  416.         }

  417.     }
  418.    
  419.    
  420.     @Override
  421.     public void delete(ConfigurazioneGenerale configurazioneGenerale) throws ServiceException,NotImplementedException {
  422.        
  423.         Connection connection = null;
  424.         boolean oldValueAutoCommit = false;
  425.         boolean rollback = false;
  426.         try{
  427.            
  428.             // check parameters
  429.             if(configurazioneGenerale==null){
  430.                 throw this.newServiceExceptionParameterIsNull();
  431.             }

  432.             // ISQLQueryObject
  433.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  434.             sqlQueryObject.setANDLogicOperator(true);
  435.             // Connection sql
  436.             connection = this.jdbcServiceManager.getConnection();

  437.             // transaction
  438.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  439.                 oldValueAutoCommit = connection.getAutoCommit();
  440.                 connection.setAutoCommit(false);
  441.             }

  442.             this.serviceCRUD.delete(this.jdbcProperties,this.log,connection,sqlQueryObject,configurazioneGenerale);

  443.         }catch(ServiceException | NotImplementedException e){
  444.             rollback = true;
  445.             this.logError(e); throw e;
  446.         }catch(Exception e){
  447.             rollback = true;
  448.             this.logError(e); throw new ServiceException("Delete not completed: "+e.getMessage(),e);
  449.         }finally{
  450.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  451.         }
  452.    
  453.     }
  454.    
  455.     @Override
  456.     public void delete() throws ServiceException,NotImplementedException {
  457.        
  458.         Connection connection = null;
  459.         boolean oldValueAutoCommit = false;
  460.         boolean rollback = false;
  461.         try{
  462.            
  463.             // ISQLQueryObject
  464.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  465.             sqlQueryObject.setANDLogicOperator(true);
  466.             // Connection sql
  467.             connection = this.jdbcServiceManager.getConnection();

  468.             // transaction
  469.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  470.                 oldValueAutoCommit = connection.getAutoCommit();
  471.                 connection.setAutoCommit(false);
  472.             }

  473.             this.serviceCRUD.delete(this.jdbcProperties,this.log,connection,sqlQueryObject,null);  

  474.         }catch(ServiceException | NotImplementedException e){
  475.             rollback = true;
  476.             this.logError(e); throw e;
  477.         }catch(Exception e){
  478.             rollback = true;
  479.             this.logError(e); throw new ServiceException("Delete not completed: "+e.getMessage(),e);
  480.         }finally{
  481.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  482.         }
  483.    
  484.     }



  485.    
  486.     // -- DB
  487.    
  488.     @Override
  489.     public void deleteById(long tableId) throws ServiceException, NotImplementedException {
  490.        
  491.         Connection connection = null;
  492.         boolean oldValueAutoCommit = false;
  493.         boolean rollback = false;
  494.         try{
  495.            
  496.             // check parameters
  497.             if(tableId<=0){
  498.                 throw new ServiceException("Parameter 'tableId' is less equals 0");
  499.             }
  500.        
  501.             // ISQLQueryObject
  502.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  503.             sqlQueryObject.setANDLogicOperator(true);
  504.             // Connection sql
  505.             connection = this.jdbcServiceManager.getConnection();

  506.             // transaction
  507.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  508.                 oldValueAutoCommit = connection.getAutoCommit();
  509.                 connection.setAutoCommit(false);
  510.             }

  511.             this.serviceCRUD.deleteById(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId);
  512.    
  513.         }catch(ServiceException | NotImplementedException e){
  514.             rollback = true;
  515.             this.logError(e); throw e;
  516.         }catch(Exception e){
  517.             rollback = true;
  518.             this.logError(e); throw new ServiceException("DeleteById(tableId) not completed: "+e.getMessage(),e);
  519.         }finally{
  520.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  521.         }
  522.    
  523.     }
  524.    
  525.     @Override
  526.     public int nativeUpdate(String sql,Object ... param) throws ServiceException, NotImplementedException {
  527.        
  528.         Connection connection = null;
  529.         boolean oldValueAutoCommit = false;
  530.         boolean rollback = false;
  531.         try{
  532.            
  533.             // check parameters
  534.             if(sql==null){
  535.                 throw new ServiceException("Parameter 'sql' is null");
  536.             }
  537.        
  538.             // ISQLQueryObject
  539.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  540.             sqlQueryObject.setANDLogicOperator(true);
  541.             // Connection sql
  542.             connection = this.jdbcServiceManager.getConnection();

  543.             // transaction
  544.             if(this.jdbcProperties.isAutomaticTransactionManagement()){
  545.                 oldValueAutoCommit = connection.getAutoCommit();
  546.                 connection.setAutoCommit(false);
  547.             }

  548.             return this.serviceCRUD.nativeUpdate(this.jdbcProperties,this.log,connection,sqlQueryObject,sql,param);
  549.    
  550.         }catch(ServiceException | NotImplementedException e){
  551.             rollback = true;
  552.             this.logError(e); throw e;
  553.         }catch(Exception e){
  554.             rollback = true;
  555.             this.logError(e); throw new ServiceException("DeleteById(tableId) not completed: "+e.getMessage(),e);
  556.         }finally{
  557.             this.releaseResources(rollback, connection, oldValueAutoCommit);
  558.         }
  559.    
  560.     }
  561.    
  562. }