JDBCAccordoServizioParteComuneAzioneServiceSearchImpl.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.commons.search.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.IJDBCServiceSearchWithId;
  31. import org.openspcoop2.core.commons.search.IdAccordoServizioParteComuneAzione;
  32. import org.openspcoop2.generic_project.utils.UtilsTemplate;
  33. import org.openspcoop2.generic_project.beans.CustomField;
  34. import org.openspcoop2.generic_project.beans.InUse;
  35. import org.openspcoop2.generic_project.beans.IField;
  36. import org.openspcoop2.generic_project.beans.NonNegativeNumber;
  37. import org.openspcoop2.generic_project.beans.UnionExpression;
  38. import org.openspcoop2.generic_project.beans.Union;
  39. import org.openspcoop2.generic_project.beans.FunctionField;
  40. import org.openspcoop2.generic_project.exception.MultipleResultException;
  41. import org.openspcoop2.generic_project.exception.NotFoundException;
  42. import org.openspcoop2.generic_project.exception.NotImplementedException;
  43. import org.openspcoop2.generic_project.exception.ServiceException;
  44. import org.openspcoop2.generic_project.expression.IExpression;
  45. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  46. import org.openspcoop2.generic_project.dao.jdbc.JDBCPaginatedExpression;

  47. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  48. import org.openspcoop2.core.commons.search.dao.jdbc.converter.AccordoServizioParteComuneAzioneFieldConverter;
  49. import org.openspcoop2.core.commons.search.dao.jdbc.fetch.AccordoServizioParteComuneAzioneFetch;
  50. import org.openspcoop2.core.commons.search.dao.IDBAccordoServizioParteComuneServiceSearch;
  51. import org.openspcoop2.core.commons.search.AccordoServizioParteComune;
  52. import org.openspcoop2.core.commons.search.AccordoServizioParteComuneAzione;
  53. import org.openspcoop2.core.commons.search.IdAccordoServizioParteComune;

  54. /**    
  55.  * JDBCAccordoServizioParteComuneAzioneServiceSearchImpl
  56.  *
  57.  * @author Poli Andrea (poli@link.it)
  58.  * @author $Author$
  59.  * @version $Rev$, $Date$
  60.  */
  61. public class JDBCAccordoServizioParteComuneAzioneServiceSearchImpl implements IJDBCServiceSearchWithId<AccordoServizioParteComuneAzione, IdAccordoServizioParteComuneAzione, JDBCServiceManager> {

  62.     private AccordoServizioParteComuneAzioneFieldConverter _accordoServizioParteComuneAzioneFieldConverter = null;
  63.     public AccordoServizioParteComuneAzioneFieldConverter getAccordoServizioParteComuneAzioneFieldConverter() {
  64.         if(this._accordoServizioParteComuneAzioneFieldConverter==null){
  65.             this._accordoServizioParteComuneAzioneFieldConverter = new AccordoServizioParteComuneAzioneFieldConverter(this.jdbcServiceManager.getJdbcProperties().getDatabaseType());
  66.         }      
  67.         return this._accordoServizioParteComuneAzioneFieldConverter;
  68.     }
  69.     @Override
  70.     public ISQLFieldConverter getFieldConverter() {
  71.         return this.getAccordoServizioParteComuneAzioneFieldConverter();
  72.     }
  73.    
  74.     private AccordoServizioParteComuneAzioneFetch accordoServizioParteComuneAzioneFetch = new AccordoServizioParteComuneAzioneFetch();
  75.     public AccordoServizioParteComuneAzioneFetch getAccordoServizioParteComuneAzioneFetch() {
  76.         return this.accordoServizioParteComuneAzioneFetch;
  77.     }
  78.     @Override
  79.     public IJDBCFetch getFetch() {
  80.         return getAccordoServizioParteComuneAzioneFetch();
  81.     }
  82.    
  83.    
  84.     private JDBCServiceManager jdbcServiceManager = null;

  85.     @Override
  86.     public void setServiceManager(JDBCServiceManager serviceManager) throws ServiceException{
  87.         this.jdbcServiceManager = serviceManager;
  88.     }
  89.    
  90.     @Override
  91.     public JDBCServiceManager getServiceManager() throws ServiceException{
  92.         return this.jdbcServiceManager;
  93.     }
  94.     public JDBCServiceManager getServiceManager(Connection connection, JDBCServiceManagerProperties jdbcProperties, Logger log) throws ServiceException{
  95.         return new JDBCServiceManager(connection, jdbcProperties, log);
  96.     }
  97.    

  98.     @Override
  99.     public IdAccordoServizioParteComuneAzione convertToId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, AccordoServizioParteComuneAzione accordoServizioParteComuneAzione) throws NotImplementedException, ServiceException, Exception{
  100.    
  101.         IdAccordoServizioParteComuneAzione idAccordoServizioParteComuneAzione = new IdAccordoServizioParteComuneAzione();
  102.         idAccordoServizioParteComuneAzione.setNome(accordoServizioParteComuneAzione.getNome());
  103.         idAccordoServizioParteComuneAzione.setIdAccordoServizioParteComune(accordoServizioParteComuneAzione.getIdAccordoServizioParteComune());
  104.         return idAccordoServizioParteComuneAzione;
  105.     }
  106.    
  107.     @Override
  108.     public AccordoServizioParteComuneAzione get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdAccordoServizioParteComuneAzione id, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException,Exception {
  109.         Long id_accordoServizioParteComuneAzione = ( (id!=null && id.getId()!=null && id.getId()>0) ? id.getId() : this.findIdAccordoServizioParteComuneAzione(jdbcProperties, log, connection, sqlQueryObject, id, true));
  110.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, id_accordoServizioParteComuneAzione,idMappingResolutionBehaviour);
  111.        
  112.        
  113.     }
  114.    
  115.     @Override
  116.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdAccordoServizioParteComuneAzione id) throws MultipleResultException, NotImplementedException, ServiceException,Exception {

  117.         Long id_accordoServizioParteComuneAzione = this.findIdAccordoServizioParteComuneAzione(jdbcProperties, log, connection, sqlQueryObject, id, false);
  118.         return id_accordoServizioParteComuneAzione != null && id_accordoServizioParteComuneAzione > 0;
  119.        
  120.     }
  121.    
  122.     @Override
  123.     public List<IdAccordoServizioParteComuneAzione> findAllIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException, ServiceException,Exception {

  124.         List<IdAccordoServizioParteComuneAzione> list = new ArrayList<IdAccordoServizioParteComuneAzione>();

  125.         // TODO: implementazione non efficiente.
  126.         // Per ottenere una implementazione efficiente:
  127.         // 1. Usare metodo select di questa classe indirizzando esattamente i field necessari a create l'ID logico
  128.         // 2. Usare metodo getAccordoServizioParteComuneAzioneFetch() sul risultato della select per ottenere un oggetto AccordoServizioParteComuneAzione
  129.         //    La fetch con la map inserirĂ  nell'oggetto solo i valori estratti
  130.         // 3. Usare metodo convertToId per ottenere l'id

  131.         List<Long> ids = this.findAllTableIds(jdbcProperties, log, connection, sqlQueryObject, expression);
  132.        
  133.         for(Long id: ids) {
  134.             AccordoServizioParteComuneAzione accordoServizioParteComuneAzione = this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour);
  135.             IdAccordoServizioParteComuneAzione idAccordoServizioParteComuneAzione = this.convertToId(jdbcProperties,log,connection,sqlQueryObject,accordoServizioParteComuneAzione);
  136.             list.add(idAccordoServizioParteComuneAzione);
  137.         }

  138.         return list;
  139.        
  140.     }
  141.    
  142.     @Override
  143.     public List<AccordoServizioParteComuneAzione> findAll(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException, ServiceException,Exception {

  144.         List<AccordoServizioParteComuneAzione> list = new ArrayList<AccordoServizioParteComuneAzione>();
  145.        
  146.         // TODO: implementazione non efficiente.
  147.         // Per ottenere una implementazione efficiente:
  148.         // 1. Usare metodo select di questa classe indirizzando esattamente i field necessari
  149.         // 2. Usare metodo getAccordoServizioParteComuneAzioneFetch() sul risultato della select per ottenere un oggetto AccordoServizioParteComuneAzione
  150.         //    La fetch con la map inserirĂ  nell'oggetto solo i valori estratti

  151.         List<Long> ids = this.findAllTableIds(jdbcProperties, log, connection, sqlQueryObject, expression);
  152.        
  153.         for(Long id: ids) {
  154.             list.add(this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour));
  155.         }

  156.         return list;      
  157.        
  158.     }
  159.    
  160.     @Override
  161.     public AccordoServizioParteComuneAzione find(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour)
  162.         throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException,Exception {

  163.         long id = this.findTableId(jdbcProperties, log, connection, sqlQueryObject, expression);
  164.         if(id>0){
  165.             return this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour);
  166.         }else{
  167.             throw new NotFoundException("Entry with id["+id+"] not found");
  168.         }
  169.        
  170.     }
  171.    
  172.     @Override
  173.     public NonNegativeNumber count(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws NotImplementedException, ServiceException,Exception {
  174.        
  175.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareCount(jdbcProperties, log, connection, sqlQueryObject, expression,
  176.                                                 this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model());
  177.        
  178.         sqlQueryObject.addSelectCountField(this.getAccordoServizioParteComuneAzioneFieldConverter().toTable(AccordoServizioParteComuneAzione.model())+".id","tot",true);
  179.        
  180.         joinEngine(expression,sqlQueryObject);
  181.        
  182.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.count(jdbcProperties, log, connection, sqlQueryObject, expression,
  183.                                                                             this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model(),listaQuery);
  184.     }

  185.     @Override
  186.     public InUse inUse(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdAccordoServizioParteComuneAzione id) throws NotFoundException, NotImplementedException, ServiceException,Exception {
  187.        
  188.         Long id_accordoServizioParteComuneAzione = this.findIdAccordoServizioParteComuneAzione(jdbcProperties, log, connection, sqlQueryObject, id, true);
  189.         return this.inUseEngine(jdbcProperties, log, connection, sqlQueryObject, id_accordoServizioParteComuneAzione);
  190.        
  191.     }

  192.     @Override
  193.     public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  194.                                                     JDBCPaginatedExpression paginatedExpression, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  195.         return this.select(jdbcProperties, log, connection, sqlQueryObject,
  196.                                 paginatedExpression, false, field);
  197.     }
  198.    
  199.     @Override
  200.     public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  201.                                                     JDBCPaginatedExpression paginatedExpression, boolean distinct, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  202.         List<Map<String,Object>> map =
  203.             this.select(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, distinct, new IField[]{field});
  204.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.selectSingleObject(map);
  205.     }
  206.    
  207.     @Override
  208.     public List<Map<String,Object>> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  209.                                                     JDBCPaginatedExpression paginatedExpression, IField ... field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  210.         return this.select(jdbcProperties, log, connection, sqlQueryObject,
  211.                                 paginatedExpression, false, field);
  212.     }
  213.    
  214.     @Override
  215.     public List<Map<String,Object>> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  216.                                                     JDBCPaginatedExpression paginatedExpression, boolean distinct, IField ... field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  217.        
  218.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,paginatedExpression,field);
  219.         try{
  220.        
  221.             ISQLQueryObject sqlQueryObjectDistinct =
  222.                         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSqlQueryObjectForSelectDistinct(distinct,sqlQueryObject, paginatedExpression, log,
  223.                                                 this.getAccordoServizioParteComuneAzioneFieldConverter(), field);

  224.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, sqlQueryObjectDistinct);
  225.            
  226.         }finally{
  227.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,paginatedExpression,field);
  228.         }
  229.     }

  230.     @Override
  231.     public Object aggregate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  232.                                                     JDBCExpression expression, FunctionField functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  233.         Map<String,Object> map =
  234.             this.aggregate(jdbcProperties, log, connection, sqlQueryObject, expression, new FunctionField[]{functionField});
  235.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.selectAggregateObject(map,functionField);
  236.     }
  237.    
  238.     @Override
  239.     public Map<String,Object> aggregate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  240.                                                     JDBCExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {                                                  
  241.        
  242.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,expression,functionField);
  243.         try{
  244.             List<Map<String,Object>> list = selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression);
  245.             return list.get(0);
  246.         }finally{
  247.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,expression,functionField);
  248.         }
  249.     }

  250.     @Override
  251.     public List<Map<String,Object>> groupBy(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  252.                                                     JDBCExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  253.        
  254.         if(expression.getGroupByFields().isEmpty()){
  255.             throw new ServiceException("GroupBy conditions not found in expression");
  256.         }
  257.        
  258.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,expression,functionField);
  259.         try{
  260.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression);
  261.         }finally{
  262.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,expression,functionField);
  263.         }
  264.     }
  265.    

  266.     @Override
  267.     public List<Map<String,Object>> groupBy(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  268.                                                     JDBCPaginatedExpression paginatedExpression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  269.        
  270.         if(paginatedExpression.getGroupByFields().isEmpty()){
  271.             throw new ServiceException("GroupBy conditions not found in expression");
  272.         }
  273.        
  274.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,paginatedExpression,functionField);
  275.         try{
  276.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression);
  277.         }finally{
  278.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,paginatedExpression,functionField);
  279.         }
  280.     }
  281.    
  282.     protected List<Map<String,Object>> selectEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  283.                                                 IExpression expression) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  284.         return selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression, null);
  285.     }
  286.     protected List<Map<String,Object>> selectEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  287.                                                 IExpression expression, ISQLQueryObject sqlQueryObjectDistinct) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  288.        
  289.         List<Object> listaQuery = new ArrayList<>();
  290.         List<JDBCObject> listaParams = new ArrayList<>();
  291.         List<Object> returnField = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSelect(jdbcProperties, log, connection, sqlQueryObject,
  292.                                 expression, this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model(),
  293.                                 listaQuery,listaParams);
  294.        
  295.         joinEngine(expression,sqlQueryObject);
  296.        
  297.         List<Map<String,Object>> list = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.select(jdbcProperties, log, connection,
  298.                                         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSqlQueryObjectForSelectDistinct(sqlQueryObject,sqlQueryObjectDistinct),
  299.                                         expression, this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model(),
  300.                                         listaQuery,listaParams,returnField);
  301.         if(list!=null && !list.isEmpty()){
  302.             return list;
  303.         }
  304.         else{
  305.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  306.         }
  307.     }
  308.    
  309.     @Override
  310.     public List<Map<String,Object>> union(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  311.                                                 Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException,Exception {    
  312.        
  313.         List<ISQLQueryObject> sqlQueryObjectInnerList = new ArrayList<>();
  314.         List<JDBCObject> jdbcObjects = new ArrayList<>();
  315.         List<Class<?>> returnClassTypes = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareUnion(jdbcProperties, log, connection, sqlQueryObject,
  316.                                 this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model(),
  317.                                 sqlQueryObjectInnerList, jdbcObjects, union, unionExpression);
  318.        
  319.         if(unionExpression!=null){
  320.             for (int i = 0; i < unionExpression.length; i++) {
  321.                 UnionExpression ue = unionExpression[i];
  322.                 IExpression expression = ue.getExpression();
  323.                 joinEngine(expression,sqlQueryObjectInnerList.get(i));
  324.             }
  325.         }
  326.        
  327.         List<Map<String,Object>> list = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.union(jdbcProperties, log, connection, sqlQueryObject,
  328.                                         this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model(),
  329.                                         sqlQueryObjectInnerList, jdbcObjects, returnClassTypes, union, unionExpression);
  330.         if(list!=null && !list.isEmpty()){
  331.             return list;
  332.         }
  333.         else{
  334.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  335.         }                              
  336.     }
  337.    
  338.     @Override
  339.     public NonNegativeNumber unionCount(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  340.                                                 Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException,Exception {    
  341.        
  342.         List<ISQLQueryObject> sqlQueryObjectInnerList = new ArrayList<>();
  343.         List<JDBCObject> jdbcObjects = new ArrayList<>();
  344.         List<Class<?>> returnClassTypes = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareUnionCount(jdbcProperties, log, connection, sqlQueryObject,
  345.                                 this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model(),
  346.                                 sqlQueryObjectInnerList, jdbcObjects, union, unionExpression);
  347.        
  348.         if(unionExpression!=null){
  349.             for (int i = 0; i < unionExpression.length; i++) {
  350.                 UnionExpression ue = unionExpression[i];
  351.                 IExpression expression = ue.getExpression();
  352.                 joinEngine(expression,sqlQueryObjectInnerList.get(i));
  353.             }
  354.         }
  355.        
  356.         NonNegativeNumber number = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.unionCount(jdbcProperties, log, connection, sqlQueryObject,
  357.                                         this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model(),
  358.                                         sqlQueryObjectInnerList, jdbcObjects, returnClassTypes, union, unionExpression);
  359.         if(number!=null && number.longValue()>=0){
  360.             return number;
  361.         }
  362.         else{
  363.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  364.         }
  365.     }



  366.     // -- ConstructorExpression

  367.     @Override
  368.     public JDBCExpression newExpression(Logger log) throws NotImplementedException, ServiceException {
  369.         try{
  370.             return new JDBCExpression(this.getAccordoServizioParteComuneAzioneFieldConverter());
  371.         }catch(Exception e){
  372.             throw new ServiceException(e);
  373.         }
  374.     }


  375.     @Override
  376.     public JDBCPaginatedExpression newPaginatedExpression(Logger log) throws NotImplementedException, ServiceException {
  377.         try{
  378.             return new JDBCPaginatedExpression(this.getAccordoServizioParteComuneAzioneFieldConverter());
  379.         }catch(Exception e){
  380.             throw new ServiceException(e);
  381.         }
  382.     }
  383.    
  384.     @Override
  385.     public JDBCExpression toExpression(JDBCPaginatedExpression paginatedExpression, Logger log) throws NotImplementedException, ServiceException {
  386.         try{
  387.             return new JDBCExpression(paginatedExpression);
  388.         }catch(Exception e){
  389.             throw new ServiceException(e);
  390.         }
  391.     }

  392.     @Override
  393.     public JDBCPaginatedExpression toPaginatedExpression(JDBCExpression expression, Logger log) throws NotImplementedException, ServiceException {
  394.         try{
  395.             return new JDBCPaginatedExpression(expression);
  396.         }catch(Exception e){
  397.             throw new ServiceException(e);
  398.         }
  399.     }
  400.    
  401.    
  402.    
  403.     // -- DB

  404.     @Override
  405.     public void mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdAccordoServizioParteComuneAzione id, AccordoServizioParteComuneAzione obj) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  406.         _mappingTableIds(jdbcProperties,log,connection,sqlQueryObject,obj,
  407.                 this.get(jdbcProperties,log,connection,sqlQueryObject,id,null));
  408.     }
  409.    
  410.     @Override
  411.     public void mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, AccordoServizioParteComuneAzione obj) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  412.         _mappingTableIds(jdbcProperties,log,connection,sqlQueryObject,obj,
  413.                 this.get(jdbcProperties,log,connection,sqlQueryObject,tableId,null));
  414.     }
  415.     private void _mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, AccordoServizioParteComuneAzione obj, AccordoServizioParteComuneAzione imgSaved) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  416.         if(imgSaved==null){
  417.             return;
  418.         }
  419.         obj.setId(imgSaved.getId());
  420.         if(obj.getIdAccordoServizioParteComune()!=null &&
  421.                 imgSaved.getIdAccordoServizioParteComune()!=null){
  422.             obj.getIdAccordoServizioParteComune().setId(imgSaved.getIdAccordoServizioParteComune().getId());
  423.             if(obj.getIdAccordoServizioParteComune().getIdSoggetto()!=null &&
  424.                     imgSaved.getIdAccordoServizioParteComune().getIdSoggetto()!=null){
  425.                 obj.getIdAccordoServizioParteComune().getIdSoggetto().setId(imgSaved.getIdAccordoServizioParteComune().getIdSoggetto().getId());
  426.             }
  427.         }

  428.     }
  429.    
  430.     @Override
  431.     public AccordoServizioParteComuneAzione get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  432.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId), idMappingResolutionBehaviour);
  433.     }
  434.    
  435.     private AccordoServizioParteComuneAzione getEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  436.    
  437.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  438.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  439.        
  440.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();
  441.                
  442.         AccordoServizioParteComuneAzione accordoServizioParteComuneAzione = new AccordoServizioParteComuneAzione();
  443.        

  444.         // Object accordoServizioParteComuneAzione
  445.         ISQLQueryObject sqlQueryObjectGet_accordoServizioParteComuneAzione = sqlQueryObjectGet.newSQLQueryObject();
  446.         sqlQueryObjectGet_accordoServizioParteComuneAzione.setANDLogicOperator(true);
  447.         sqlQueryObjectGet_accordoServizioParteComuneAzione.addFromTable(this.getAccordoServizioParteComuneAzioneFieldConverter().toTable(AccordoServizioParteComuneAzione.model()));
  448.         sqlQueryObjectGet_accordoServizioParteComuneAzione.addSelectField("id");
  449.         sqlQueryObjectGet_accordoServizioParteComuneAzione.addSelectField(this.getAccordoServizioParteComuneAzioneFieldConverter().toColumn(AccordoServizioParteComuneAzione.model().NOME,true));
  450.         sqlQueryObjectGet_accordoServizioParteComuneAzione.addWhereCondition("id=?");

  451.         // Get accordoServizioParteComuneAzione
  452.         accordoServizioParteComuneAzione = (AccordoServizioParteComuneAzione) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet_accordoServizioParteComuneAzione.createSQLQuery(), jdbcProperties.isShowSql(), AccordoServizioParteComuneAzione.model(), this.getAccordoServizioParteComuneAzioneFetch(),
  453.             new JDBCObject(tableId,Long.class));


  454.         // Recupero idAccordo
  455.         ISQLQueryObject sqlQueryObjectGet_accordoServizioParteComune = sqlQueryObjectGet.newSQLQueryObject();
  456.         sqlQueryObjectGet_accordoServizioParteComune.addFromTable(this.getAccordoServizioParteComuneAzioneFieldConverter().toTable(AccordoServizioParteComuneAzione.model()));
  457.         sqlQueryObjectGet_accordoServizioParteComune.addSelectField("id_accordo");
  458.         sqlQueryObjectGet_accordoServizioParteComune.setANDLogicOperator(true);
  459.         sqlQueryObjectGet_accordoServizioParteComune.addWhereCondition("id=?");
  460.        
  461.         // Recupero _accordoServizioParteComune_soggetto
  462.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_accordoServizioParteComune = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  463.                 new JDBCObject(accordoServizioParteComuneAzione.getId(), Long.class)
  464.         };
  465.         Long id_accordoServizioParteComune =
  466.             (Long) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet_accordoServizioParteComune.createSQLQuery(), jdbcProperties.isShowSql(),
  467.             Long.class, searchParams_accordoServizioParteComune);
  468.        
  469.         IDBAccordoServizioParteComuneServiceSearch search = ((IDBAccordoServizioParteComuneServiceSearch)this.getServiceManager(connection, jdbcProperties, log).getAccordoServizioParteComuneServiceSearch());
  470.         AccordoServizioParteComune as = search.get(id_accordoServizioParteComune);
  471.         IdAccordoServizioParteComune idAccordo = search.convertToId(as);
  472.         accordoServizioParteComuneAzione.setIdAccordoServizioParteComune(idAccordo);
  473.        
  474.         return accordoServizioParteComuneAzione;  
  475.    
  476.     }
  477.    
  478.     @Override
  479.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  480.         return this._exists(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId));
  481.     }
  482.    
  483.     private boolean _exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  484.    
  485.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  486.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  487.                
  488.         boolean existsAccordoServizioParteComuneAzione = false;

  489.         sqlQueryObject = sqlQueryObject.newSQLQueryObject();
  490.         sqlQueryObject.setANDLogicOperator(true);

  491.         sqlQueryObject.addFromTable(this.getAccordoServizioParteComuneAzioneFieldConverter().toTable(AccordoServizioParteComuneAzione.model()));
  492.         sqlQueryObject.addSelectField(this.getAccordoServizioParteComuneAzioneFieldConverter().toColumn(AccordoServizioParteComuneAzione.model().NOME,true));
  493.         sqlQueryObject.addWhereCondition("id=?");


  494.         // Exists accordoServizioParteComuneAzione
  495.         existsAccordoServizioParteComuneAzione = jdbcUtilities.exists(sqlQueryObject.createSQLQuery(), jdbcProperties.isShowSql(),
  496.             new JDBCObject(tableId,Long.class));

  497.        
  498.         return existsAccordoServizioParteComuneAzione;
  499.    
  500.     }
  501.    
  502.     private void joinEngine(IExpression expression, ISQLQueryObject sqlQueryObject) throws NotImplementedException, ServiceException, Exception{
  503.    
  504.         if(expression.inUseModel(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE,false)){
  505.             String tableName1 = this.getAccordoServizioParteComuneAzioneFieldConverter().toAliasTable(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE);
  506.             String tableName2 = this.getAccordoServizioParteComuneAzioneFieldConverter().toAliasTable(AccordoServizioParteComuneAzione.model());
  507.             sqlQueryObject.addWhereCondition(tableName1+".id="+tableName2+".id_accordo");
  508.         }
  509.         if(expression.inUseModel(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE.ID_SOGGETTO,false)){
  510.             String tableName1 = this.getAccordoServizioParteComuneAzioneFieldConverter().toAliasTable(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE);
  511.             String tableName2 = this.getAccordoServizioParteComuneAzioneFieldConverter().toAliasTable(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE.ID_SOGGETTO);
  512.             sqlQueryObject.addWhereCondition(tableName1+".id_referente="+tableName2+".id");
  513.         }
  514.        
  515.         if(expression.inUseModel(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE.ID_SOGGETTO,false)){
  516.             if(expression.inUseModel(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE,false)==false){
  517.                 sqlQueryObject.addFromTable(this.getAccordoServizioParteComuneAzioneFieldConverter().toTable(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE));
  518.             }
  519.         }
  520.        
  521.     }
  522.    
  523.     protected java.util.List<Object> getRootTablePrimaryKeyValuesEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdAccordoServizioParteComuneAzione id) throws NotFoundException, ServiceException, NotImplementedException, Exception{
  524.         // Identificativi
  525.         java.util.List<Object> rootTableIdValues = new java.util.ArrayList<>();
  526.         Long longId = this.findIdAccordoServizioParteComuneAzione(jdbcProperties, log, connection, sqlQueryObject.newSQLQueryObject(), id, true);
  527.         rootTableIdValues.add(longId);
  528.         return rootTableIdValues;
  529.     }
  530.    
  531.     protected Map<String, List<IField>> getMapTableToPKColumnEngine() throws NotImplementedException, Exception{
  532.    
  533.         AccordoServizioParteComuneAzioneFieldConverter converter = this.getAccordoServizioParteComuneAzioneFieldConverter();
  534.         Map<String, List<IField>> mapTableToPKColumn = new java.util.HashMap<>();
  535.         UtilsTemplate<IField> utilities = new UtilsTemplate<>();

  536.         // AccordoServizioParteComuneAzione.model()
  537.         mapTableToPKColumn.put(converter.toTable(AccordoServizioParteComuneAzione.model()),
  538.             utilities.newList(
  539.                 new CustomField("id", Long.class, "id", converter.toTable(AccordoServizioParteComuneAzione.model()))
  540.             ));

  541.         // AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE
  542.         mapTableToPKColumn.put(converter.toTable(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE),
  543.             utilities.newList(
  544.                 new CustomField("id", Long.class, "id", converter.toTable(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE))
  545.             ));

  546.         // AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE.ID_SOGGETTO
  547.         mapTableToPKColumn.put(converter.toTable(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE.ID_SOGGETTO),
  548.             utilities.newList(
  549.                 new CustomField("id", Long.class, "id", converter.toTable(AccordoServizioParteComuneAzione.model().ID_ACCORDO_SERVIZIO_PARTE_COMUNE.ID_SOGGETTO))
  550.             ));
  551.        
  552.         return mapTableToPKColumn;      
  553.     }
  554.    
  555.     @Override
  556.     public List<Long> findAllTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression paginatedExpression) throws ServiceException, NotImplementedException, Exception {
  557.        
  558.         List<Long> list = new ArrayList<Long>();

  559.         sqlQueryObject.setSelectDistinct(true);
  560.         sqlQueryObject.setANDLogicOperator(true);
  561.         sqlQueryObject.addSelectField(this.getAccordoServizioParteComuneAzioneFieldConverter().toTable(AccordoServizioParteComuneAzione.model())+".id");
  562.         Class<?> objectIdClass = Long.class;
  563.        
  564.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFindAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  565.                                                 this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model());
  566.        
  567.         joinEngine(paginatedExpression,sqlQueryObject);
  568.        
  569.         List<Object> listObjects = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.findAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  570.                                                                             this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model(), objectIdClass, listaQuery);
  571.         for(Object object: listObjects) {
  572.             list.add((Long)object);
  573.         }

  574.         return list;
  575.        
  576.     }
  577.    
  578.     @Override
  579.     public long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException, Exception {
  580.    
  581.         sqlQueryObject.setSelectDistinct(true);
  582.         sqlQueryObject.setANDLogicOperator(true);
  583.         sqlQueryObject.addSelectField(this.getAccordoServizioParteComuneAzioneFieldConverter().toTable(AccordoServizioParteComuneAzione.model())+".id");
  584.         Class<?> objectIdClass = Long.class;
  585.        
  586.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFind(jdbcProperties, log, connection, sqlQueryObject, expression,
  587.                                                 this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model());
  588.        
  589.         joinEngine(expression,sqlQueryObject);

  590.         Object res = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.find(jdbcProperties, log, connection, sqlQueryObject, expression,
  591.                                                         this.getAccordoServizioParteComuneAzioneFieldConverter(), AccordoServizioParteComuneAzione.model(), objectIdClass, listaQuery);
  592.         if(res!=null && (((Long) res).longValue()>0) ){
  593.             return ((Long) res).longValue();
  594.         }
  595.         else{
  596.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  597.         }
  598.        
  599.     }

  600.     @Override
  601.     public InUse inUse(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws ServiceException, NotFoundException, NotImplementedException, Exception {
  602.         return this.inUseEngine(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId));
  603.     }

  604.     private InUse inUseEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId) throws ServiceException, NotFoundException, NotImplementedException, Exception {

  605.         InUse inUse = new InUse();
  606.         inUse.setInUse(false);
  607.        
  608.         /*
  609.          * TODO: implement code that checks whether the object identified by the id parameter is used by other objects
  610.         */
  611.        
  612.         // Delete this line when you have implemented the method
  613.         int throwNotImplemented = 1;
  614.         if(throwNotImplemented==1){
  615.                 throw new NotImplementedException("NotImplemented");
  616.         }
  617.         // Delete this line when you have implemented the method

  618.         return inUse;

  619.     }
  620.    
  621.     @Override
  622.     public IdAccordoServizioParteComuneAzione findId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, boolean throwNotFound)
  623.             throws NotFoundException, ServiceException, NotImplementedException, Exception {
  624.        
  625.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  626.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);

  627.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();              

  628.         // Object _accordoServizioParteComuneAzione
  629.         sqlQueryObjectGet.addFromTable(this.getAccordoServizioParteComuneAzioneFieldConverter().toTable(AccordoServizioParteComuneAzione.model()));
  630.         sqlQueryObjectGet.addSelectField(this.getAccordoServizioParteComuneAzioneFieldConverter().toColumn(AccordoServizioParteComuneAzione.model().NOME,true));
  631.         sqlQueryObjectGet.addSelectField("id_accordo");
  632.         sqlQueryObjectGet.setANDLogicOperator(true);
  633.         sqlQueryObjectGet.addWhereCondition("id=?");

  634.         // Recupero _accordoServizioParteComuneAzione
  635.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_accordoServizioParteComuneAzione = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  636.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(tableId,Long.class)
  637.         };
  638.         List<Class<?>> listaFieldIdReturnType_accordoServizioParteComuneAzione = new ArrayList<Class<?>>();
  639.         listaFieldIdReturnType_accordoServizioParteComuneAzione.add(String.class);
  640.         listaFieldIdReturnType_accordoServizioParteComuneAzione.add(Long.class);
  641.         org.openspcoop2.core.commons.search.IdAccordoServizioParteComuneAzione id_accordoServizioParteComuneAzione = null;
  642.         List<Object> listaFieldId_accordoServizioParteComuneAzione = jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(),
  643.                 listaFieldIdReturnType_accordoServizioParteComuneAzione, searchParams_accordoServizioParteComuneAzione);
  644.         if(listaFieldId_accordoServizioParteComuneAzione==null || listaFieldId_accordoServizioParteComuneAzione.size()<=0){
  645.             if(throwNotFound){
  646.                 throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  647.             }
  648.         }
  649.         else{
  650.             // set _accordoServizioParteComuneAzione
  651.             id_accordoServizioParteComuneAzione = new org.openspcoop2.core.commons.search.IdAccordoServizioParteComuneAzione();
  652.             id_accordoServizioParteComuneAzione.setNome((String)listaFieldId_accordoServizioParteComuneAzione.get(0));
  653.             Long idAccordoFK = (Long) listaFieldId_accordoServizioParteComuneAzione.get(1);
  654.             id_accordoServizioParteComuneAzione.
  655.                 setIdAccordoServizioParteComune(((IDBAccordoServizioParteComuneServiceSearch)this.getServiceManager(connection, jdbcProperties, log).
  656.                         getAccordoServizioParteComuneServiceSearch()).findId(idAccordoFK, true));
  657.         }
  658.        
  659.         return id_accordoServizioParteComuneAzione;
  660.        
  661.     }

  662.     @Override
  663.     public Long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdAccordoServizioParteComuneAzione id, boolean throwNotFound)
  664.             throws NotFoundException, ServiceException, NotImplementedException, Exception {
  665.    
  666.         return this.findIdAccordoServizioParteComuneAzione(jdbcProperties,log,connection,sqlQueryObject,id,throwNotFound);
  667.            
  668.     }
  669.    
  670.     @Override
  671.     public List<List<Object>> nativeQuery(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  672.                                             String sql,List<Class<?>> returnClassTypes,Object ... param) throws ServiceException,NotFoundException,NotImplementedException,Exception{
  673.        
  674.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.nativeQuery(jdbcProperties, log, connection, sqlQueryObject,
  675.                                                                                             sql,returnClassTypes,param);
  676.                                                        
  677.     }
  678.    
  679.     protected Long findIdAccordoServizioParteComuneAzione(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdAccordoServizioParteComuneAzione id, boolean throwNotFound) throws NotFoundException, ServiceException, NotImplementedException, Exception {

  680.         if(jdbcProperties==null) {
  681.             throw new ServiceException("Param jdbcProperties is null");
  682.         }
  683.         if(sqlQueryObject==null) {
  684.             throw new ServiceException("Param sqlQueryObject is null");
  685.         }
  686.         if(id==null) {
  687.             throw new ServiceException("Param id is null");
  688.         }
  689.        
  690.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  691.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);

  692.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();

  693.         if(id.getIdAccordoServizioParteComune()==null){
  694.             throw new ServiceException("IdAccordoServizioParteComune non fornito");
  695.         }
  696.         if(id.getIdAccordoServizioParteComune().getIdSoggetto()==null){
  697.             throw new ServiceException("IdAccordoServizioParteComune.getIdSoggetto non fornito");
  698.         }
  699.        
  700.         // Recupero idAccordo
  701.         AccordoServizioParteComune as = this.getServiceManager(connection, jdbcProperties, log).getAccordoServizioParteComuneServiceSearch().get(id.getIdAccordoServizioParteComune());
  702.        
  703.              
  704.         // Object _accordoServizioParteComuneAzione
  705.         sqlQueryObjectGet.addFromTable(this.getAccordoServizioParteComuneAzioneFieldConverter().toTable(AccordoServizioParteComuneAzione.model()));
  706.         sqlQueryObjectGet.addSelectField("id");
  707.         // Devono essere mappati nella where condition i metodi dell'oggetto id.getXXX
  708.         sqlQueryObjectGet.setANDLogicOperator(true);
  709.         sqlQueryObjectGet.setSelectDistinct(true);
  710.         sqlQueryObjectGet.addWhereCondition(this.getAccordoServizioParteComuneAzioneFieldConverter().toColumn(AccordoServizioParteComuneAzione.model().NOME,true)+"=?");
  711.         sqlQueryObjectGet.addWhereCondition("id_accordo=?");
  712.        
  713.         // Recupero _accordoServizioParteComuneAzione
  714.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_accordoServizioParteComuneAzione = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  715.                 new JDBCObject(id.getNome(), String.class),
  716.                 new JDBCObject(as.getId(), Long.class)
  717.         };
  718.         Long id_accordoServizioParteComuneAzione = null;
  719.         try{
  720.             id_accordoServizioParteComuneAzione = (Long) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(),
  721.                         Long.class, searchParams_accordoServizioParteComuneAzione);
  722.         }catch(NotFoundException notFound){
  723.             if(throwNotFound){
  724.                 throw new NotFoundException(notFound);
  725.             }
  726.         }
  727.         if(id_accordoServizioParteComuneAzione==null || id_accordoServizioParteComuneAzione<=0){
  728.             if(throwNotFound){
  729.                 throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  730.             }
  731.         }
  732.        
  733.         return id_accordoServizioParteComuneAzione;
  734.     }
  735. }