JDBCTransazioneInfoServiceSearchImpl.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 java.util.List;
  22. import java.util.ArrayList;
  23. import java.util.Map;

  24. import java.sql.Connection;

  25. import org.slf4j.Logger;

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

  27. import org.openspcoop2.generic_project.expression.impl.sql.ISQLFieldConverter;
  28. import org.openspcoop2.generic_project.dao.jdbc.utils.IJDBCFetch;
  29. import org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject;
  30. import org.openspcoop2.generic_project.dao.jdbc.IJDBCServiceSearchWithoutId;
  31. import org.openspcoop2.generic_project.beans.InUse;
  32. import org.openspcoop2.generic_project.beans.IField;
  33. import org.openspcoop2.generic_project.beans.NonNegativeNumber;
  34. import org.openspcoop2.generic_project.beans.UnionExpression;
  35. import org.openspcoop2.generic_project.beans.Union;
  36. import org.openspcoop2.generic_project.beans.FunctionField;
  37. import org.openspcoop2.generic_project.exception.MultipleResultException;
  38. import org.openspcoop2.generic_project.exception.NotFoundException;
  39. import org.openspcoop2.generic_project.exception.NotImplementedException;
  40. import org.openspcoop2.generic_project.exception.ServiceException;
  41. import org.openspcoop2.generic_project.expression.IExpression;
  42. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  43. import org.openspcoop2.generic_project.dao.jdbc.JDBCPaginatedExpression;

  44. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  45. import org.openspcoop2.core.transazioni.dao.jdbc.converter.TransazioneInfoFieldConverter;
  46. import org.openspcoop2.core.transazioni.dao.jdbc.fetch.TransazioneInfoFetch;
  47. import org.openspcoop2.core.transazioni.TransazioneInfo;

  48. /**    
  49.  * JDBCTransazioneInfoServiceSearchImpl
  50.  *
  51.  * @author Poli Andrea (poli@link.it)
  52.  * @author $Author$
  53.  * @version $Rev$, $Date$
  54.  */
  55. public class JDBCTransazioneInfoServiceSearchImpl implements IJDBCServiceSearchWithoutId<TransazioneInfo, JDBCServiceManager> {

  56.     private TransazioneInfoFieldConverter _transazioneInfoFieldConverter = null;
  57.     public TransazioneInfoFieldConverter getTransazioneInfoFieldConverter() {
  58.         if(this._transazioneInfoFieldConverter==null){
  59.             this._transazioneInfoFieldConverter = new TransazioneInfoFieldConverter(this.jdbcServiceManager.getJdbcProperties().getDatabaseType());
  60.         }      
  61.         return this._transazioneInfoFieldConverter;
  62.     }
  63.     @Override
  64.     public ISQLFieldConverter getFieldConverter() {
  65.         return this.getTransazioneInfoFieldConverter();
  66.     }
  67.    
  68.     private TransazioneInfoFetch transazioneInfoFetch = new TransazioneInfoFetch();
  69.     public TransazioneInfoFetch getTransazioneInfoFetch() {
  70.         return this.transazioneInfoFetch;
  71.     }
  72.     @Override
  73.     public IJDBCFetch getFetch() {
  74.         return getTransazioneInfoFetch();
  75.     }
  76.    
  77.    
  78.     private JDBCServiceManager jdbcServiceManager = null;

  79.     @Override
  80.     public void setServiceManager(JDBCServiceManager serviceManager) throws ServiceException{
  81.         this.jdbcServiceManager = serviceManager;
  82.     }
  83.    
  84.     @Override
  85.     public JDBCServiceManager getServiceManager() throws ServiceException{
  86.         return this.jdbcServiceManager;
  87.     }
  88.    

  89.    
  90.    
  91.    
  92.    
  93.     @Override
  94.     public List<TransazioneInfo> findAll(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException, ServiceException,Exception {

  95.         List<TransazioneInfo> list = new ArrayList<TransazioneInfo>();
  96.        
  97.         // TODO: implementazione non efficiente.
  98.         // Per ottenere una implementazione efficiente:
  99.         // 1. Usare metodo select di questa classe indirizzando esattamente i field necessari
  100.         // 2. Usare metodo getTransazioneInfoFetch() sul risultato della select per ottenere un oggetto TransazioneInfo
  101.         //    La fetch con la map inserirĂ  nell'oggetto solo i valori estratti

  102.         List<Object> ids = this._findAllObjectIds(jdbcProperties, log, connection, sqlQueryObject, expression);
  103.        
  104.         for(Object id: ids) {
  105.             list.add(this.getEngine(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour));
  106.         }

  107.         return list;      
  108.        
  109.     }
  110.    
  111.     @Override
  112.     public TransazioneInfo find(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour)
  113.         throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException,Exception {

  114.         Object id = this._findObjectId(jdbcProperties, log, connection, sqlQueryObject, expression);
  115.         if(id!=null){
  116.             return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour);
  117.         }else{
  118.             throw new NotFoundException("Entry with id["+id+"] not found");
  119.         }
  120.        
  121.     }
  122.    
  123.     @Override
  124.     public NonNegativeNumber count(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws NotImplementedException, ServiceException,Exception {
  125.        
  126.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareCount(jdbcProperties, log, connection, sqlQueryObject, expression,
  127.                                                 this.getTransazioneInfoFieldConverter(), TransazioneInfo.model());
  128.        
  129.         sqlQueryObject.addSelectCountField("tot");
  130.        
  131.         joinEngine(expression,sqlQueryObject);
  132.        
  133.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.count(jdbcProperties, log, connection, sqlQueryObject, expression,
  134.                                                                             this.getTransazioneInfoFieldConverter(), TransazioneInfo.model(),listaQuery);
  135.     }


  136.     @Override
  137.     public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  138.                                                     JDBCPaginatedExpression paginatedExpression, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  139.         return this.select(jdbcProperties, log, connection, sqlQueryObject,
  140.                                 paginatedExpression, false, field);
  141.     }
  142.    
  143.     @Override
  144.     public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  145.                                                     JDBCPaginatedExpression paginatedExpression, boolean distinct, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  146.         List<Map<String,Object>> map =
  147.             this.select(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, distinct, new IField[]{field});
  148.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.selectSingleObject(map);
  149.     }
  150.    
  151.     @Override
  152.     public List<Map<String,Object>> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  153.                                                     JDBCPaginatedExpression paginatedExpression, IField ... field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  154.         return this.select(jdbcProperties, log, connection, sqlQueryObject,
  155.                                 paginatedExpression, false, field);
  156.     }
  157.    
  158.     @Override
  159.     public List<Map<String,Object>> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  160.                                                     JDBCPaginatedExpression paginatedExpression, boolean distinct, IField ... field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  161.        
  162.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,paginatedExpression,field);
  163.         try{
  164.        
  165.             ISQLQueryObject sqlQueryObjectDistinct =
  166.                         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSqlQueryObjectForSelectDistinct(distinct,sqlQueryObject, paginatedExpression, log,
  167.                                                 this.getTransazioneInfoFieldConverter(), field);

  168.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, sqlQueryObjectDistinct);
  169.            
  170.         }finally{
  171.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,paginatedExpression,field);
  172.         }
  173.     }

  174.     @Override
  175.     public Object aggregate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  176.                                                     JDBCExpression expression, FunctionField functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  177.         Map<String,Object> map =
  178.             this.aggregate(jdbcProperties, log, connection, sqlQueryObject, expression, new FunctionField[]{functionField});
  179.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.selectAggregateObject(map,functionField);
  180.     }
  181.    
  182.     @Override
  183.     public Map<String,Object> aggregate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  184.                                                     JDBCExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {                                                  
  185.        
  186.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,expression,functionField);
  187.         try{
  188.             List<Map<String,Object>> list = selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression);
  189.             return list.get(0);
  190.         }finally{
  191.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,expression,functionField);
  192.         }
  193.     }

  194.     @Override
  195.     public List<Map<String,Object>> groupBy(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  196.                                                     JDBCExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  197.        
  198.         if(expression.getGroupByFields().isEmpty()){
  199.             throw new ServiceException("GroupBy conditions not found in expression");
  200.         }
  201.        
  202.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,expression,functionField);
  203.         try{
  204.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression);
  205.         }finally{
  206.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,expression,functionField);
  207.         }
  208.     }
  209.    

  210.     @Override
  211.     public List<Map<String,Object>> groupBy(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  212.                                                     JDBCPaginatedExpression paginatedExpression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  213.        
  214.         if(paginatedExpression.getGroupByFields().isEmpty()){
  215.             throw new ServiceException("GroupBy conditions not found in expression");
  216.         }
  217.        
  218.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,paginatedExpression,functionField);
  219.         try{
  220.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression);
  221.         }finally{
  222.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,paginatedExpression,functionField);
  223.         }
  224.     }
  225.    
  226.     protected List<Map<String,Object>> selectEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  227.                                                 IExpression expression) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  228.         return selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression, null);
  229.     }
  230.     protected List<Map<String,Object>> selectEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  231.                                                 IExpression expression, ISQLQueryObject sqlQueryObjectDistinct) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  232.        
  233.         List<Object> listaQuery = new ArrayList<>();
  234.         List<JDBCObject> listaParams = new ArrayList<>();
  235.         List<Object> returnField = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSelect(jdbcProperties, log, connection, sqlQueryObject,
  236.                                 expression, this.getTransazioneInfoFieldConverter(), TransazioneInfo.model(),
  237.                                 listaQuery,listaParams);
  238.        
  239.         joinEngine(expression,sqlQueryObject);
  240.        
  241.         List<Map<String,Object>> list = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.select(jdbcProperties, log, connection,
  242.                                         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSqlQueryObjectForSelectDistinct(sqlQueryObject,sqlQueryObjectDistinct),
  243.                                         expression, this.getTransazioneInfoFieldConverter(), TransazioneInfo.model(),
  244.                                         listaQuery,listaParams,returnField);
  245.         if(list!=null && !list.isEmpty()){
  246.             return list;
  247.         }
  248.         else{
  249.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  250.         }
  251.     }
  252.    
  253.     @Override
  254.     public List<Map<String,Object>> union(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  255.                                                 Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException,Exception {    
  256.        
  257.         List<ISQLQueryObject> sqlQueryObjectInnerList = new ArrayList<>();
  258.         List<JDBCObject> jdbcObjects = new ArrayList<>();
  259.         List<Class<?>> returnClassTypes = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareUnion(jdbcProperties, log, connection, sqlQueryObject,
  260.                                 this.getTransazioneInfoFieldConverter(), TransazioneInfo.model(),
  261.                                 sqlQueryObjectInnerList, jdbcObjects, union, unionExpression);
  262.        
  263.         if(unionExpression!=null){
  264.             for (int i = 0; i < unionExpression.length; i++) {
  265.                 UnionExpression ue = unionExpression[i];
  266.                 IExpression expression = ue.getExpression();
  267.                 joinEngine(expression,sqlQueryObjectInnerList.get(i));
  268.             }
  269.         }
  270.        
  271.         List<Map<String,Object>> list = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.union(jdbcProperties, log, connection, sqlQueryObject,
  272.                                         this.getTransazioneInfoFieldConverter(), TransazioneInfo.model(),
  273.                                         sqlQueryObjectInnerList, jdbcObjects, returnClassTypes, union, unionExpression);
  274.         if(list!=null && !list.isEmpty()){
  275.             return list;
  276.         }
  277.         else{
  278.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  279.         }                              
  280.     }
  281.    
  282.     @Override
  283.     public NonNegativeNumber unionCount(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  284.                                                 Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException,Exception {    
  285.        
  286.         List<ISQLQueryObject> sqlQueryObjectInnerList = new ArrayList<>();
  287.         List<JDBCObject> jdbcObjects = new ArrayList<>();
  288.         List<Class<?>> returnClassTypes = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareUnionCount(jdbcProperties, log, connection, sqlQueryObject,
  289.                                 this.getTransazioneInfoFieldConverter(), TransazioneInfo.model(),
  290.                                 sqlQueryObjectInnerList, jdbcObjects, union, unionExpression);
  291.        
  292.         if(unionExpression!=null){
  293.             for (int i = 0; i < unionExpression.length; i++) {
  294.                 UnionExpression ue = unionExpression[i];
  295.                 IExpression expression = ue.getExpression();
  296.                 joinEngine(expression,sqlQueryObjectInnerList.get(i));
  297.             }
  298.         }
  299.        
  300.         NonNegativeNumber number = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.unionCount(jdbcProperties, log, connection, sqlQueryObject,
  301.                                         this.getTransazioneInfoFieldConverter(), TransazioneInfo.model(),
  302.                                         sqlQueryObjectInnerList, jdbcObjects, returnClassTypes, union, unionExpression);
  303.         if(number!=null && number.longValue()>=0){
  304.             return number;
  305.         }
  306.         else{
  307.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  308.         }
  309.     }



  310.     // -- ConstructorExpression

  311.     @Override
  312.     public JDBCExpression newExpression(Logger log) throws NotImplementedException, ServiceException {
  313.         try{
  314.             return new JDBCExpression(this.getTransazioneInfoFieldConverter());
  315.         }catch(Exception e){
  316.             throw new ServiceException(e);
  317.         }
  318.     }


  319.     @Override
  320.     public JDBCPaginatedExpression newPaginatedExpression(Logger log) throws NotImplementedException, ServiceException {
  321.         try{
  322.             return new JDBCPaginatedExpression(this.getTransazioneInfoFieldConverter());
  323.         }catch(Exception e){
  324.             throw new ServiceException(e);
  325.         }
  326.     }
  327.    
  328.     @Override
  329.     public JDBCExpression toExpression(JDBCPaginatedExpression paginatedExpression, Logger log) throws NotImplementedException, ServiceException {
  330.         try{
  331.             return new JDBCExpression(paginatedExpression);
  332.         }catch(Exception e){
  333.             throw new ServiceException(e);
  334.         }
  335.     }

  336.     @Override
  337.     public JDBCPaginatedExpression toPaginatedExpression(JDBCExpression expression, Logger log) throws NotImplementedException, ServiceException {
  338.         try{
  339.             return new JDBCPaginatedExpression(expression);
  340.         }catch(Exception e){
  341.             throw new ServiceException(e);
  342.         }
  343.     }
  344.    
  345.    
  346.    
  347.     // -- DB

  348.    
  349.     @Override
  350.     public TransazioneInfo get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  351.         throw new NotImplementedException("Table without long id column PK");
  352.     }
  353.    
  354.     protected TransazioneInfo getEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Object objectId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  355.    
  356.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  357.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  358.        
  359.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();
  360.                
  361.         TransazioneInfo transazioneInfo = new TransazioneInfo();
  362.        

  363.         // Object transazioneInfo
  364.         ISQLQueryObject sqlQueryObjectGet_transazioneInfo = sqlQueryObjectGet.newSQLQueryObject();
  365.         sqlQueryObjectGet_transazioneInfo.setANDLogicOperator(true);
  366.         sqlQueryObjectGet_transazioneInfo.addFromTable(this.getTransazioneInfoFieldConverter().toTable(TransazioneInfo.model()));
  367.         sqlQueryObjectGet_transazioneInfo.addSelectField(this.getTransazioneInfoFieldConverter().toColumn(TransazioneInfo.model().TIPO,true));
  368.         sqlQueryObjectGet_transazioneInfo.addSelectField(this.getTransazioneInfoFieldConverter().toColumn(TransazioneInfo.model().DATA,true));
  369.         sqlQueryObjectGet_transazioneInfo.addWhereCondition(this.getTransazioneInfoFieldConverter().toColumn(TransazioneInfo.model().TIPO,true)+"=?");

  370.         // Get transazioneInfo
  371.         transazioneInfo = (TransazioneInfo) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet_transazioneInfo.createSQLQuery(), jdbcProperties.isShowSql(), TransazioneInfo.model(), this.getTransazioneInfoFetch(),
  372.             new JDBCObject(objectId,objectId.getClass()));              
  373.        
  374.         return transazioneInfo;  
  375.    
  376.     }
  377.    
  378.     @Override
  379.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  380.         throw new NotImplementedException("Table without long id column PK");
  381.     }
  382.    
  383.     protected boolean _exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Object objectId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  384.    
  385.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  386.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  387.                
  388.         boolean existsTransazioneInfo = false;

  389.         sqlQueryObject = sqlQueryObject.newSQLQueryObject();
  390.         sqlQueryObject.setANDLogicOperator(true);

  391.         sqlQueryObject.addFromTable(this.getTransazioneInfoFieldConverter().toTable(TransazioneInfo.model()));
  392.         sqlQueryObject.addSelectField(this.getTransazioneInfoFieldConverter().toColumn(TransazioneInfo.model().TIPO,true));
  393.         sqlQueryObject.addWhereCondition(this.getTransazioneInfoFieldConverter().toColumn(TransazioneInfo.model().TIPO,true)+"=?");

  394.         // Exists transazioneInfo
  395.         existsTransazioneInfo = jdbcUtilities.exists(sqlQueryObject.createSQLQuery(), jdbcProperties.isShowSql(),
  396.             new JDBCObject(objectId,objectId.getClass()));

  397.                    
  398.         return existsTransazioneInfo;
  399.    
  400.     }
  401.    
  402.     private void joinEngine(IExpression expression, ISQLQueryObject sqlQueryObject) throws NotImplementedException, ServiceException, Exception{
  403.    
  404.         // nop
  405.        
  406.     }
  407.    
  408.     protected java.util.List<Object> getRootTablePrimaryKeyValuesEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, TransazioneInfo transazioneInfo) throws NotFoundException, ServiceException, NotImplementedException, Exception{
  409.         // Identificativi
  410.         java.util.List<Object> rootTableIdValues = new java.util.ArrayList<>();
  411.         return rootTableIdValues;
  412.     }
  413.    
  414.     protected Map<String, List<IField>> getMapTableToPKColumnEngine() throws NotImplementedException, Exception{
  415.    
  416.         Map<String, List<IField>> mapTableToPKColumn = new java.util.HashMap<>();
  417.         return mapTableToPKColumn;
  418.        
  419.     }
  420.    
  421.     @Override
  422.     public List<Long> findAllTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression paginatedExpression) throws ServiceException, NotImplementedException, Exception {
  423.        
  424.         throw new NotImplementedException("Table without long id column PK");
  425.        
  426.     }
  427.     public List<Object> _findAllObjectIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression paginatedExpression) throws ServiceException, NotImplementedException, Exception {
  428.        

  429.         sqlQueryObject.setSelectDistinct(true);
  430.         sqlQueryObject.setANDLogicOperator(true);
  431.         sqlQueryObject.addSelectField(this.getTransazioneInfoFieldConverter().toColumn(TransazioneInfo.model().TIPO,true));
  432.         Class<?> objectIdClass = String.class;
  433.        
  434.         // NOTE: if you have a object id with more columns set the and condition in sqlQueryObject:
  435.         //          sqlQueryObject.setANDLogicOperator(true);
  436.         //       and use a list (List<Class<?>> objectIdClass) as parameter for method org.openspcoop2.generic_project.dao.jdbc.utils.JDBCUtilities.findAll
  437.         //       The method return a List<List<Object>>.
  438.                
  439.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFindAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  440.                                                 this.getTransazioneInfoFieldConverter(), TransazioneInfo.model());
  441.        
  442.         joinEngine(paginatedExpression,sqlQueryObject);
  443.        
  444.         List<Object> listObjects = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.findAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  445.                                                                             this.getTransazioneInfoFieldConverter(), TransazioneInfo.model(), objectIdClass, listaQuery);
  446.         return listObjects;
  447.        
  448.     }
  449.    
  450.     @Override
  451.     public long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException, Exception {
  452.    
  453.         throw new NotImplementedException("Table without long id column PK");
  454.        
  455.     }
  456.    
  457.     public Object _findObjectId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException, Exception {
  458.        
  459.         sqlQueryObject.setSelectDistinct(true);
  460.         sqlQueryObject.setANDLogicOperator(true);
  461.         sqlQueryObject.addSelectField(this.getTransazioneInfoFieldConverter().toColumn(TransazioneInfo.model().TIPO,true));
  462.         Class<?> objectIdClass = String.class;
  463.        
  464.         // NOTE: if you have a object id with more columns set the and condition in sqlQueryObject:
  465.         //          sqlQueryObject.setANDLogicOperator(true);
  466.         //       and use a list (List<Class<?>> objectIdClass) as parameter for method org.openspcoop2.generic_project.dao.jdbc.utils.JDBCUtilities.find
  467.         //       The method return a list.
  468.        
  469.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFind(jdbcProperties, log, connection, sqlQueryObject, expression,
  470.                                                 this.getTransazioneInfoFieldConverter(), TransazioneInfo.model());
  471.        
  472.         joinEngine(expression,sqlQueryObject);

  473.         Object res = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.find(jdbcProperties, log, connection, sqlQueryObject, expression,
  474.                                                         this.getTransazioneInfoFieldConverter(), TransazioneInfo.model(), objectIdClass, listaQuery);
  475.         if(res!=null){
  476.             return res;
  477.         }
  478.         else{
  479.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  480.         }
  481.        
  482.     }

  483.     @Override
  484.     public InUse inUse(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws ServiceException, NotFoundException, NotImplementedException, Exception {
  485.         throw new NotImplementedException("Table without long id column PK");
  486.     }

  487.     protected InUse inUseEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Object objectId) throws ServiceException, NotFoundException, NotImplementedException, Exception {

  488.         InUse inUse = new InUse();
  489.         inUse.setInUse(false);
  490.        
  491.         /*
  492.          * TODO: implement code that checks whether the object identified by the id parameter is used by other objects
  493.         */
  494.        
  495.         // Delete this line when you have implemented the method
  496.         int throwNotImplemented = 1;
  497.         if(throwNotImplemented==1){
  498.                 throw new NotImplementedException("NotImplemented");
  499.         }
  500.         // Delete this line when you have implemented the method

  501.         return inUse;

  502.     }
  503.    

  504.    
  505.     @Override
  506.     public List<List<Object>> nativeQuery(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  507.                                             String sql,List<Class<?>> returnClassTypes,Object ... param) throws ServiceException,NotFoundException,NotImplementedException,Exception{
  508.        
  509.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.nativeQuery(jdbcProperties, log, connection, sqlQueryObject,
  510.                                                                                             sql,returnClassTypes,param);
  511.                                                        
  512.     }
  513.    
  514. }