package com.ejie.m62fb.dao;

import com.ejie.x38.dto.Pagination;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.ejie.m62fb.model.M62fbp20s0s00;

/**
 * M62fbp20s0s00DaoImpl generated by UDA, 06-nov-2012 10:00:25.
 * 
XXXX
 */

@Repository
@Transactional
public class M62fbp20s0s00DaoImpl implements M62fbp20s0s00Dao {
	private JdbcTemplate jdbcTemplate;
	private RowMapper<M62fbp20s0s00> rwMap = new RowMapper<M62fbp20s0s00>() {
		public M62fbp20s0s00 mapRow(ResultSet resultSet, int rowNum)
				throws SQLException {
			return new M62fbp20s0s00(resultSet.getString("NIFTITULAR"),
					resultSet.getLong("NUMCORRELNIF"),
					resultSet.getString("CODTIPOCLAVE"),
					resultSet.getInt("ITIPIDEN"),
					resultSet.getString("NOMAPELLIDO1"),
					resultSet.getString("NOMAPELLIDO2"),
					resultSet.getString("NOMNOMBRE"),
					resultSet.getDate("FECNACIMIENTO"),
					resultSet.getString("INDSEXO"), resultSet.getInt("ISEXO"),
					resultSet.getString("INDESTADOCIVIL"),
					resultSet.getInt("IESTCIVI"), resultSet.getLong("CPAIS"),
					resultSet.getString("DPAIS"),
					resultSet.getLong("CTERRITO"),
					resultSet.getString("CODPROVINCIA"),
					resultSet.getString("DTERRITO"),
					resultSet.getInt("CMUNICIP"),
					resultSet.getString("CODMUNICIPIO"),
					resultSet.getString("DMUNICIP"),
					resultSet.getString("DDIRECCI"),
					resultSet.getString("EMAIL"), resultSet.getInt("NTELEFNO"),
					resultSet.getInt("NUMTLFNO2"),
					resultSet.getString("CODCALLE"),
					resultSet.getString("CODPORTAL"),
					resultSet.getString("DECSITVIV"),
					resultSet.getString("DECMANO"),
					resultSet.getString("CODPOSTAL"),
					resultSet.getInt("NUMCODPOSTAL"),
					resultSet.getDate("FECALTA"),
					resultSet.getString("DIRIPUSUARIO"),
					resultSet.getDate("FEHULTMODIF"),
					resultSet.getString("CODUSUULTMODIF"),
					resultSet.getInt("IDEREGISTRO"),
					resultSet.getString("CODAPLICACION"),
					resultSet.getInt("IDPERSONA"),
					resultSet.getString("DESCALLE"));
		}
	};

	/**
	 * Method use to set the datasource.
	 * 
	 * @param dataSource
	 *            DataSource
	 * @return
	 */
	@Resource
	public void setDataSource(DataSource dataSource) {
		this.jdbcTemplate = new JdbcTemplate(dataSource);
	}

	/**
	 * Inserts a single row in the M62fbp20s0s00 table.
	 * 
	 * @param m62fbp20s0s00
	 *            Pagination
	 * @return M62fbp20s0s00
	 */
	public M62fbp20s0s00 add(M62fbp20s0s00 m62fbp20s0s00) {
		String query = "INSERT INTO M62P20T0S00 (NIF_TITULAR, NUM_CORREL_NIF, COD_TIPO_CLAVE, ITIPIDEN, NOM_APELLIDO_1, NOM_APELLIDO_2, NOM_NOMBRE, FEC_NACIMIENTO, IND_SEXO, ISEXO, IND_ESTADO_CIVIL, IESTCIVI, CPAIS, DPAIS, CTERRITO, COD_PROVINCIA, DTERRITO, CMUNICIP, COD_MUNICIPIO, DMUNICIP, DDIRECCI, EMAIL, NTELEFNO, NUM_TLFNO_2, COD_CALLE, COD_PORTAL, DEC_SIT_VIV, DEC_MANO, COD_POSTAL, NUM_COD_POSTAL, FEC_ALTA, DIR_IP_USUARIO, FEH_ULT_MODIF, COD_USU_ULT_MODIF, IDE_REGISTRO, COD_APLICACION, ID_PERSONA, DES_CALLE) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		this.jdbcTemplate.update(query, m62fbp20s0s00.getNifTitular(),
				m62fbp20s0s00.getNumCorrelNif(),
				m62fbp20s0s00.getCodTipoClave(), m62fbp20s0s00.getItipiden(),
				m62fbp20s0s00.getNomApellido1(),
				m62fbp20s0s00.getNomApellido2(), m62fbp20s0s00.getNomNombre(),
				m62fbp20s0s00.getFecNacimiento(), m62fbp20s0s00.getIndSexo(),
				m62fbp20s0s00.getIsexo(), m62fbp20s0s00.getIndEstadoCivil(),
				m62fbp20s0s00.getIestcivi(), m62fbp20s0s00.getCpais(),
				m62fbp20s0s00.getDpais(), m62fbp20s0s00.getCterrito(),
				m62fbp20s0s00.getCodProvincia(), m62fbp20s0s00.getDterrito(),
				m62fbp20s0s00.getCmunicip(), m62fbp20s0s00.getCodMunicipio(),
				m62fbp20s0s00.getDmunicip(), m62fbp20s0s00.getDdirecci(),
				m62fbp20s0s00.getEmail(), m62fbp20s0s00.getNtelefno(),
				m62fbp20s0s00.getNumTlfno2(), m62fbp20s0s00.getCodCalle(),
				m62fbp20s0s00.getCodPortal(), m62fbp20s0s00.getDecSitViv(),
				m62fbp20s0s00.getDecMano(), m62fbp20s0s00.getCodPostal(),
				m62fbp20s0s00.getNumCodPostal(), m62fbp20s0s00.getFecAlta(),
				m62fbp20s0s00.getDirIpUsuario(),
				m62fbp20s0s00.getFehUltModif(),
				m62fbp20s0s00.getCodUsuUltModif(),
				m62fbp20s0s00.getIdeRegistro(),
				m62fbp20s0s00.getCodAplicacion(), m62fbp20s0s00.getIdPersona(),
				m62fbp20s0s00.getDesCalle());
		return m62fbp20s0s00;
	}

	/**
	 * Updates a single row in the M62fbp20s0s00 table.
	 * 
	 * @param m62fbp20s0s00
	 *            Pagination
	 * @return M62fbp20s0s00
	 */
	public M62fbp20s0s00 update(M62fbp20s0s00 m62fbp20s0s00) {
		String query = "UPDATE M62P20T0S00 SET  WHERE NIF_TITULAR=? AND NUM_CORREL_NIF=? AND COD_TIPO_CLAVE=? AND ITIPIDEN=? AND NOM_APELLIDO_1=? AND NOM_APELLIDO_2=? AND NOM_NOMBRE=? AND FEC_NACIMIENTO=? AND IND_SEXO=? AND ISEXO=? AND IND_ESTADO_CIVIL=? AND IESTCIVI=? AND CPAIS=? AND DPAIS=? AND CTERRITO=? AND COD_PROVINCIA=? AND DTERRITO=? AND CMUNICIP=? AND COD_MUNICIPIO=? AND DMUNICIP=? AND DDIRECCI=? AND EMAIL=? AND NTELEFNO=? AND NUM_TLFNO_2=? AND COD_CALLE=? AND COD_PORTAL=? AND DEC_SIT_VIV=? AND DEC_MANO=? AND COD_POSTAL=? AND NUM_COD_POSTAL=? AND FEC_ALTA=? AND DIR_IP_USUARIO=? AND FEH_ULT_MODIF=? AND COD_USU_ULT_MODIF=? AND IDE_REGISTRO=? AND COD_APLICACION=? AND ID_PERSONA=? AND DES_CALLE=?";
		this.jdbcTemplate.update(query, m62fbp20s0s00.getNifTitular(),
				m62fbp20s0s00.getNumCorrelNif(),
				m62fbp20s0s00.getCodTipoClave(), m62fbp20s0s00.getItipiden(),
				m62fbp20s0s00.getNomApellido1(),
				m62fbp20s0s00.getNomApellido2(), m62fbp20s0s00.getNomNombre(),
				m62fbp20s0s00.getFecNacimiento(), m62fbp20s0s00.getIndSexo(),
				m62fbp20s0s00.getIsexo(), m62fbp20s0s00.getIndEstadoCivil(),
				m62fbp20s0s00.getIestcivi(), m62fbp20s0s00.getCpais(),
				m62fbp20s0s00.getDpais(), m62fbp20s0s00.getCterrito(),
				m62fbp20s0s00.getCodProvincia(), m62fbp20s0s00.getDterrito(),
				m62fbp20s0s00.getCmunicip(), m62fbp20s0s00.getCodMunicipio(),
				m62fbp20s0s00.getDmunicip(), m62fbp20s0s00.getDdirecci(),
				m62fbp20s0s00.getEmail(), m62fbp20s0s00.getNtelefno(),
				m62fbp20s0s00.getNumTlfno2(), m62fbp20s0s00.getCodCalle(),
				m62fbp20s0s00.getCodPortal(), m62fbp20s0s00.getDecSitViv(),
				m62fbp20s0s00.getDecMano(), m62fbp20s0s00.getCodPostal(),
				m62fbp20s0s00.getNumCodPostal(), m62fbp20s0s00.getFecAlta(),
				m62fbp20s0s00.getDirIpUsuario(),
				m62fbp20s0s00.getFehUltModif(),
				m62fbp20s0s00.getCodUsuUltModif(),
				m62fbp20s0s00.getIdeRegistro(),
				m62fbp20s0s00.getCodAplicacion(), m62fbp20s0s00.getIdPersona(),
				m62fbp20s0s00.getDesCalle());
		return m62fbp20s0s00;
	}

	/**
	 * Finds a single row in the M62fbp20s0s00 table.
	 * 
	 * @param m62fbp20s0s00
	 *            Pagination
	 * @return M62fbp20s0s00
	 */
	@Transactional(readOnly = true, timeout = 500)
	public M62fbp20s0s00 find(M62fbp20s0s00 m62fbp20s0s00) {
		String query = "SELECT t1.NIF_TITULAR NIFTITULAR, t1.NUM_CORREL_NIF NUMCORRELNIF, t1.COD_TIPO_CLAVE CODTIPOCLAVE, t1.ITIPIDEN ITIPIDEN, t1.NOM_APELLIDO_1 NOMAPELLIDO1, t1.NOM_APELLIDO_2 NOMAPELLIDO2, t1.NOM_NOMBRE NOMNOMBRE, t1.FEC_NACIMIENTO FECNACIMIENTO, t1.IND_SEXO INDSEXO, t1.ISEXO ISEXO, t1.IND_ESTADO_CIVIL INDESTADOCIVIL, t1.IESTCIVI IESTCIVI, t1.CPAIS CPAIS, t1.DPAIS DPAIS, t1.CTERRITO CTERRITO, t1.COD_PROVINCIA CODPROVINCIA, t1.DTERRITO DTERRITO, t1.CMUNICIP CMUNICIP, t1.COD_MUNICIPIO CODMUNICIPIO, t1.DMUNICIP DMUNICIP, t1.DDIRECCI DDIRECCI, t1.EMAIL EMAIL, t1.NTELEFNO NTELEFNO, t1.NUM_TLFNO_2 NUMTLFNO2, t1.COD_CALLE CODCALLE, t1.COD_PORTAL CODPORTAL, t1.DEC_SIT_VIV DECSITVIV, t1.DEC_MANO DECMANO, t1.COD_POSTAL CODPOSTAL, t1.NUM_COD_POSTAL NUMCODPOSTAL, t1.FEC_ALTA FECALTA, t1.DIR_IP_USUARIO DIRIPUSUARIO, t1.FEH_ULT_MODIF FEHULTMODIF, t1.COD_USU_ULT_MODIF CODUSUULTMODIF, t1.IDE_REGISTRO IDEREGISTRO, t1.COD_APLICACION CODAPLICACION, t1.ID_PERSONA IDPERSONA, t1.DES_CALLE DESCALLE FROM M62P20T0S00 t1  WHERE t1.NIF_TITULAR = ?   AND t1.NUM_CORREL_NIF = ?   AND t1.COD_TIPO_CLAVE = ?   AND t1.ITIPIDEN = ?   AND t1.NOM_APELLIDO_1 = ?   AND t1.NOM_APELLIDO_2 = ?   AND t1.NOM_NOMBRE = ?   AND t1.FEC_NACIMIENTO = ?   AND t1.IND_SEXO = ?   AND t1.ISEXO = ?   AND t1.IND_ESTADO_CIVIL = ?   AND t1.IESTCIVI = ?   AND t1.CPAIS = ?   AND t1.DPAIS = ?   AND t1.CTERRITO = ?   AND t1.COD_PROVINCIA = ?   AND t1.DTERRITO = ?   AND t1.CMUNICIP = ?   AND t1.COD_MUNICIPIO = ?   AND t1.DMUNICIP = ?   AND t1.DDIRECCI = ?   AND t1.EMAIL = ?   AND t1.NTELEFNO = ?   AND t1.NUM_TLFNO_2 = ?   AND t1.COD_CALLE = ?   AND t1.COD_PORTAL = ?   AND t1.DEC_SIT_VIV = ?   AND t1.DEC_MANO = ?   AND t1.COD_POSTAL = ?   AND t1.NUM_COD_POSTAL = ?   AND t1.FEC_ALTA = ?   AND t1.DIR_IP_USUARIO = ?   AND t1.FEH_ULT_MODIF = ?   AND t1.COD_USU_ULT_MODIF = ?   AND t1.IDE_REGISTRO = ?   AND t1.COD_APLICACION = ?   AND t1.ID_PERSONA = ?   AND t1.DES_CALLE = ?  ";

		List<M62fbp20s0s00> m62fbp20s0s00List = this.jdbcTemplate.query(query,
				this.rwMap, m62fbp20s0s00.getNifTitular(),
				m62fbp20s0s00.getNumCorrelNif(),
				m62fbp20s0s00.getCodTipoClave(), m62fbp20s0s00.getItipiden(),
				m62fbp20s0s00.getNomApellido1(),
				m62fbp20s0s00.getNomApellido2(), m62fbp20s0s00.getNomNombre(),
				m62fbp20s0s00.getFecNacimiento(), m62fbp20s0s00.getIndSexo(),
				m62fbp20s0s00.getIsexo(), m62fbp20s0s00.getIndEstadoCivil(),
				m62fbp20s0s00.getIestcivi(), m62fbp20s0s00.getCpais(),
				m62fbp20s0s00.getDpais(), m62fbp20s0s00.getCterrito(),
				m62fbp20s0s00.getCodProvincia(), m62fbp20s0s00.getDterrito(),
				m62fbp20s0s00.getCmunicip(), m62fbp20s0s00.getCodMunicipio(),
				m62fbp20s0s00.getDmunicip(), m62fbp20s0s00.getDdirecci(),
				m62fbp20s0s00.getEmail(), m62fbp20s0s00.getNtelefno(),
				m62fbp20s0s00.getNumTlfno2(), m62fbp20s0s00.getCodCalle(),
				m62fbp20s0s00.getCodPortal(), m62fbp20s0s00.getDecSitViv(),
				m62fbp20s0s00.getDecMano(), m62fbp20s0s00.getCodPostal(),
				m62fbp20s0s00.getNumCodPostal(), m62fbp20s0s00.getFecAlta(),
				m62fbp20s0s00.getDirIpUsuario(),
				m62fbp20s0s00.getFehUltModif(),
				m62fbp20s0s00.getCodUsuUltModif(),
				m62fbp20s0s00.getIdeRegistro(),
				m62fbp20s0s00.getCodAplicacion(), m62fbp20s0s00.getIdPersona(),
				m62fbp20s0s00.getDesCalle());
		return (M62fbp20s0s00) DataAccessUtils.uniqueResult(m62fbp20s0s00List);
	}

	/**
	 * Removes a single row in the M62fbp20s0s00 table.
	 * 
	 * @param m62fbp20s0s00
	 *            Pagination
	 * @return
	 */
	public void remove(M62fbp20s0s00 m62fbp20s0s00) {
		String query = "DELETE FROM M62P20T0S00 WHERE NIF_TITULAR=? AND NUM_CORREL_NIF=? AND COD_TIPO_CLAVE=? AND ITIPIDEN=? AND NOM_APELLIDO_1=? AND NOM_APELLIDO_2=? AND NOM_NOMBRE=? AND FEC_NACIMIENTO=? AND IND_SEXO=? AND ISEXO=? AND IND_ESTADO_CIVIL=? AND IESTCIVI=? AND CPAIS=? AND DPAIS=? AND CTERRITO=? AND COD_PROVINCIA=? AND DTERRITO=? AND CMUNICIP=? AND COD_MUNICIPIO=? AND DMUNICIP=? AND DDIRECCI=? AND EMAIL=? AND NTELEFNO=? AND NUM_TLFNO_2=? AND COD_CALLE=? AND COD_PORTAL=? AND DEC_SIT_VIV=? AND DEC_MANO=? AND COD_POSTAL=? AND NUM_COD_POSTAL=? AND FEC_ALTA=? AND DIR_IP_USUARIO=? AND FEH_ULT_MODIF=? AND COD_USU_ULT_MODIF=? AND IDE_REGISTRO=? AND COD_APLICACION=? AND ID_PERSONA=? AND DES_CALLE=?";
		this.jdbcTemplate.update(query, m62fbp20s0s00.getNifTitular(),
				m62fbp20s0s00.getNumCorrelNif(),
				m62fbp20s0s00.getCodTipoClave(), m62fbp20s0s00.getItipiden(),
				m62fbp20s0s00.getNomApellido1(),
				m62fbp20s0s00.getNomApellido2(), m62fbp20s0s00.getNomNombre(),
				m62fbp20s0s00.getFecNacimiento(), m62fbp20s0s00.getIndSexo(),
				m62fbp20s0s00.getIsexo(), m62fbp20s0s00.getIndEstadoCivil(),
				m62fbp20s0s00.getIestcivi(), m62fbp20s0s00.getCpais(),
				m62fbp20s0s00.getDpais(), m62fbp20s0s00.getCterrito(),
				m62fbp20s0s00.getCodProvincia(), m62fbp20s0s00.getDterrito(),
				m62fbp20s0s00.getCmunicip(), m62fbp20s0s00.getCodMunicipio(),
				m62fbp20s0s00.getDmunicip(), m62fbp20s0s00.getDdirecci(),
				m62fbp20s0s00.getEmail(), m62fbp20s0s00.getNtelefno(),
				m62fbp20s0s00.getNumTlfno2(), m62fbp20s0s00.getCodCalle(),
				m62fbp20s0s00.getCodPortal(), m62fbp20s0s00.getDecSitViv(),
				m62fbp20s0s00.getDecMano(), m62fbp20s0s00.getCodPostal(),
				m62fbp20s0s00.getNumCodPostal(), m62fbp20s0s00.getFecAlta(),
				m62fbp20s0s00.getDirIpUsuario(),
				m62fbp20s0s00.getFehUltModif(),
				m62fbp20s0s00.getCodUsuUltModif(),
				m62fbp20s0s00.getIdeRegistro(),
				m62fbp20s0s00.getCodAplicacion(), m62fbp20s0s00.getIdPersona(),
				m62fbp20s0s00.getDesCalle());
	}

	/**
	 * Finds a List of rows in the M62fbp20s0s00 table.
	 * 
	 * @param m62fbp20s0s00
	 *            M62fbp20s0s00
	 * @param pagination
	 *            Pagination
	 * @return List
	 */
	@Transactional(readOnly = true, timeout = 500)
	public List<M62fbp20s0s00> findAll(M62fbp20s0s00 m62fbp20s0s00,
			Pagination pagination) {
		StringBuilder query = new StringBuilder(
				"SELECT  t1.NIF_TITULAR NIFTITULAR,t1.NUM_CORREL_NIF NUMCORRELNIF,t1.COD_TIPO_CLAVE CODTIPOCLAVE,t1.ITIPIDEN ITIPIDEN,t1.NOM_APELLIDO_1 NOMAPELLIDO1,t1.NOM_APELLIDO_2 NOMAPELLIDO2,t1.NOM_NOMBRE NOMNOMBRE,t1.FEC_NACIMIENTO FECNACIMIENTO,t1.IND_SEXO INDSEXO,t1.ISEXO ISEXO,t1.IND_ESTADO_CIVIL INDESTADOCIVIL,t1.IESTCIVI IESTCIVI,t1.CPAIS CPAIS,t1.DPAIS DPAIS,t1.CTERRITO CTERRITO,t1.COD_PROVINCIA CODPROVINCIA,t1.DTERRITO DTERRITO,t1.CMUNICIP CMUNICIP,t1.COD_MUNICIPIO CODMUNICIPIO,t1.DMUNICIP DMUNICIP,t1.DDIRECCI DDIRECCI,t1.EMAIL EMAIL,t1.NTELEFNO NTELEFNO,t1.NUM_TLFNO_2 NUMTLFNO2,t1.COD_CALLE CODCALLE,t1.COD_PORTAL CODPORTAL,t1.DEC_SIT_VIV DECSITVIV,t1.DEC_MANO DECMANO,t1.COD_POSTAL CODPOSTAL,t1.NUM_COD_POSTAL NUMCODPOSTAL,t1.FEC_ALTA FECALTA,t1.DIR_IP_USUARIO DIRIPUSUARIO,t1.FEH_ULT_MODIF FEHULTMODIF,t1.COD_USU_ULT_MODIF CODUSUULTMODIF,t1.IDE_REGISTRO IDEREGISTRO,t1.COD_APLICACION CODAPLICACION,t1.ID_PERSONA IDPERSONA,t1.DES_CALLE DESCALLE ");
		query.append("FROM M62P20T0S00 t1 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereMap(m62fbp20s0s00);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		if (pagination != null) {
			query = pagination.getPaginationQuery(query);
		}

		return (List<M62fbp20s0s00>) this.jdbcTemplate.query(query.toString(),
				this.rwMap, params.toArray());
	}

	/**
	 * Counts rows in the M62fbp20s0s00 table.
	 * 
	 * @param m62fbp20s0s00
	 *            M62fbp20s0s00
	 * @return Long
	 */
	@Transactional(readOnly = true, timeout = 500)
	public Long findAllCount(M62fbp20s0s00 m62fbp20s0s00) {
		StringBuilder query = new StringBuilder(
				"SELECT COUNT(1) FROM M62P20T0S00 t1 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereMap(m62fbp20s0s00);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		return this.jdbcTemplate.queryForLong(query.toString(),
				params.toArray());
	}

	/**
	 * Finds rows in the M62fbp20s0s00 table using like.
	 * 
	 * @param m62fbp20s0s00
	 *            M62fbp20s0s00
	 * @param pagination
	 *            Pagination
	 * @param startsWith
	 *            Boolean
	 * @return List
	 */
	@Transactional(readOnly = true, timeout = 500)
	public List<M62fbp20s0s00> findAllLike(M62fbp20s0s00 m62fbp20s0s00,
			Pagination pagination, Boolean startsWith) {
		StringBuilder query = new StringBuilder(
				"SELECT  t1.NIF_TITULAR NIFTITULAR,t1.NUM_CORREL_NIF NUMCORRELNIF,t1.COD_TIPO_CLAVE CODTIPOCLAVE,t1.ITIPIDEN ITIPIDEN,t1.NOM_APELLIDO_1 NOMAPELLIDO1,t1.NOM_APELLIDO_2 NOMAPELLIDO2,t1.NOM_NOMBRE NOMNOMBRE,t1.FEC_NACIMIENTO FECNACIMIENTO,t1.IND_SEXO INDSEXO,t1.ISEXO ISEXO,t1.IND_ESTADO_CIVIL INDESTADOCIVIL,t1.IESTCIVI IESTCIVI,t1.CPAIS CPAIS,t1.DPAIS DPAIS,t1.CTERRITO CTERRITO,t1.COD_PROVINCIA CODPROVINCIA,t1.DTERRITO DTERRITO,t1.CMUNICIP CMUNICIP,t1.COD_MUNICIPIO CODMUNICIPIO,t1.DMUNICIP DMUNICIP,t1.DDIRECCI DDIRECCI,t1.EMAIL EMAIL,t1.NTELEFNO NTELEFNO,t1.NUM_TLFNO_2 NUMTLFNO2,t1.COD_CALLE CODCALLE,t1.COD_PORTAL CODPORTAL,t1.DEC_SIT_VIV DECSITVIV,t1.DEC_MANO DECMANO,t1.COD_POSTAL CODPOSTAL,t1.NUM_COD_POSTAL NUMCODPOSTAL,t1.FEC_ALTA FECALTA,t1.DIR_IP_USUARIO DIRIPUSUARIO,t1.FEH_ULT_MODIF FEHULTMODIF,t1.COD_USU_ULT_MODIF CODUSUULTMODIF,t1.IDE_REGISTRO IDEREGISTRO,t1.COD_APLICACION CODAPLICACION,t1.ID_PERSONA IDPERSONA,t1.DES_CALLE DESCALLE ");
		query.append("FROM M62P20T0S00 t1 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(m62fbp20s0s00,
				startsWith);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		if (pagination != null) {
			query = pagination.getPaginationQuery(query);
		}

		return (List<M62fbp20s0s00>) this.jdbcTemplate.query(query.toString(),
				this.rwMap, params.toArray());
	}

	/**
	 * Counts rows in the M62fbp20s0s00 table using like.
	 * 
	 * @param m62fbp20s0s00
	 *            M62fbp20s0s00
	 * @param startsWith
	 *            Boolean
	 * @return Long
	 */
	@Transactional(readOnly = true, timeout = 500)
	public Long findAllLikeCount(M62fbp20s0s00 m62fbp20s0s00, Boolean startsWith) {
		StringBuilder query = new StringBuilder(
				"SELECT COUNT(1) FROM M62P20T0S00 t1 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(m62fbp20s0s00,
				startsWith);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		return this.jdbcTemplate.queryForLong(query.toString(),
				params.toArray());
	}

	/**
	 * Returns a map with the needed value to create the conditions to filter by
	 * the M62fbp20s0s00 entity
	 * 
	 * @param m62fbp20s0s00
	 *            M62fbp20s0s00 Bean with the criteria values to filter by.
	 * @return Map created with two keys key query stores the sql query syntax
	 *         key params stores the parameter values to be used in the
	 *         condition sentence.
	 */
	// CHECKSTYLE:OFF CyclomaticComplexity - Generación de código de UDA
	private Map<String, ?> getWhereMap(M62fbp20s0s00 m62fbp20s0s00) {

		StringBuffer where = new StringBuffer(
				M62fbp20s0s00DaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();

		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNifTitular() != null) {
			where.append(" AND t1.NIF_TITULAR = ?");
			params.add(m62fbp20s0s00.getNifTitular());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNumCorrelNif() != null) {
			where.append(" AND t1.NUM_CORREL_NIF = ?");
			params.add(m62fbp20s0s00.getNumCorrelNif());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodTipoClave() != null) {
			where.append(" AND t1.COD_TIPO_CLAVE = ?");
			params.add(m62fbp20s0s00.getCodTipoClave());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getItipiden() != null) {
			where.append(" AND t1.ITIPIDEN = ?");
			params.add(m62fbp20s0s00.getItipiden());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNomApellido1() != null) {
			where.append(" AND t1.NOM_APELLIDO_1 = ?");
			params.add(m62fbp20s0s00.getNomApellido1());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNomApellido2() != null) {
			where.append(" AND t1.NOM_APELLIDO_2 = ?");
			params.add(m62fbp20s0s00.getNomApellido2());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNomNombre() != null) {
			where.append(" AND t1.NOM_NOMBRE = ?");
			params.add(m62fbp20s0s00.getNomNombre());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getFecNacimiento() != null) {
			where.append(" AND t1.FEC_NACIMIENTO = ?");
			params.add(m62fbp20s0s00.getFecNacimiento());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIndSexo() != null) {
			where.append(" AND t1.IND_SEXO = ?");
			params.add(m62fbp20s0s00.getIndSexo());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIsexo() != null) {
			where.append(" AND t1.ISEXO = ?");
			params.add(m62fbp20s0s00.getIsexo());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIndEstadoCivil() != null) {
			where.append(" AND t1.IND_ESTADO_CIVIL = ?");
			params.add(m62fbp20s0s00.getIndEstadoCivil());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIestcivi() != null) {
			where.append(" AND t1.IESTCIVI = ?");
			params.add(m62fbp20s0s00.getIestcivi());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCpais() != null) {
			where.append(" AND t1.CPAIS = ?");
			params.add(m62fbp20s0s00.getCpais());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDpais() != null) {
			where.append(" AND t1.DPAIS = ?");
			params.add(m62fbp20s0s00.getDpais());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCterrito() != null) {
			where.append(" AND t1.CTERRITO = ?");
			params.add(m62fbp20s0s00.getCterrito());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodProvincia() != null) {
			where.append(" AND t1.COD_PROVINCIA = ?");
			params.add(m62fbp20s0s00.getCodProvincia());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDterrito() != null) {
			where.append(" AND t1.DTERRITO = ?");
			params.add(m62fbp20s0s00.getDterrito());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCmunicip() != null) {
			where.append(" AND t1.CMUNICIP = ?");
			params.add(m62fbp20s0s00.getCmunicip());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodMunicipio() != null) {
			where.append(" AND t1.COD_MUNICIPIO = ?");
			params.add(m62fbp20s0s00.getCodMunicipio());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDmunicip() != null) {
			where.append(" AND t1.DMUNICIP = ?");
			params.add(m62fbp20s0s00.getDmunicip());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDdirecci() != null) {
			where.append(" AND t1.DDIRECCI = ?");
			params.add(m62fbp20s0s00.getDdirecci());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getEmail() != null) {
			where.append(" AND t1.EMAIL = ?");
			params.add(m62fbp20s0s00.getEmail());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNtelefno() != null) {
			where.append(" AND t1.NTELEFNO = ?");
			params.add(m62fbp20s0s00.getNtelefno());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNumTlfno2() != null) {
			where.append(" AND t1.NUM_TLFNO_2 = ?");
			params.add(m62fbp20s0s00.getNumTlfno2());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodCalle() != null) {
			where.append(" AND t1.COD_CALLE = ?");
			params.add(m62fbp20s0s00.getCodCalle());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodPortal() != null) {
			where.append(" AND t1.COD_PORTAL = ?");
			params.add(m62fbp20s0s00.getCodPortal());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDecSitViv() != null) {
			where.append(" AND t1.DEC_SIT_VIV = ?");
			params.add(m62fbp20s0s00.getDecSitViv());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDecMano() != null) {
			where.append(" AND t1.DEC_MANO = ?");
			params.add(m62fbp20s0s00.getDecMano());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodPostal() != null) {
			where.append(" AND t1.COD_POSTAL = ?");
			params.add(m62fbp20s0s00.getCodPostal());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNumCodPostal() != null) {
			where.append(" AND t1.NUM_COD_POSTAL = ?");
			params.add(m62fbp20s0s00.getNumCodPostal());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getFecAlta() != null) {
			where.append(" AND t1.FEC_ALTA = ?");
			params.add(m62fbp20s0s00.getFecAlta());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDirIpUsuario() != null) {
			where.append(" AND t1.DIR_IP_USUARIO = ?");
			params.add(m62fbp20s0s00.getDirIpUsuario());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getFehUltModif() != null) {
			where.append(" AND t1.FEH_ULT_MODIF = ?");
			params.add(m62fbp20s0s00.getFehUltModif());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodUsuUltModif() != null) {
			where.append(" AND t1.COD_USU_ULT_MODIF = ?");
			params.add(m62fbp20s0s00.getCodUsuUltModif());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIdeRegistro() != null) {
			where.append(" AND t1.IDE_REGISTRO = ?");
			params.add(m62fbp20s0s00.getIdeRegistro());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodAplicacion() != null) {
			where.append(" AND t1.COD_APLICACION = ?");
			params.add(m62fbp20s0s00.getCodAplicacion());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIdPersona() != null) {
			where.append(" AND t1.ID_PERSONA = ?");
			params.add(m62fbp20s0s00.getIdPersona());
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDesCalle() != null) {
			where.append(" AND t1.DES_CALLE = ?");
			params.add(m62fbp20s0s00.getDesCalle());
		}

		Map<String, Object> mapWhere = new HashMap<String, Object>();
		mapWhere.put("query", where);
		mapWhere.put("params", params);

		return mapWhere;
	}

	// CHECKSTYLE:ON CyclomaticComplexity - Generación de código de UDA

	/**
	 * Returns a map with the needed value to create the conditions to filter by
	 * the M62fbp20s0s00 entity
	 * 
	 * @param m62fbp20s0s00
	 *            M62fbp20s0s00 Bean with the criteria values to filter by.
	 * @param startsWith
	 *            Boolean
	 * @return Map created with two keys key query stores the sql query syntax
	 *         key params stores the parameter values to be used in the
	 *         condition sentence.
	 */
	// CHECKSTYLE:OFF CyclomaticComplexity - Generación de código de UDA
	private Map<String, ?> getWhereLikeMap(M62fbp20s0s00 m62fbp20s0s00,
			Boolean startsWith) {

		StringBuffer where = new StringBuffer(
				M62fbp20s0s00DaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();

		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNifTitular() != null) {
			where.append(" AND UPPER(t1.NIF_TITULAR) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getNifTitular().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getNifTitular().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.NIF_TITULAR IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNumCorrelNif() != null) {
			where.append(" AND t1.NUM_CORREL_NIF = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodTipoClave() != null) {
			where.append(" AND UPPER(t1.COD_TIPO_CLAVE) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getCodTipoClave().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getCodTipoClave().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.COD_TIPO_CLAVE IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getItipiden() != null) {
			where.append(" AND t1.ITIPIDEN = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNomApellido1() != null) {
			where.append(" AND UPPER(t1.NOM_APELLIDO_1) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getNomApellido1().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getNomApellido1().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.NOM_APELLIDO_1 IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNomApellido2() != null) {
			where.append(" AND UPPER(t1.NOM_APELLIDO_2) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getNomApellido2().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getNomApellido2().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.NOM_APELLIDO_2 IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNomNombre() != null) {
			where.append(" AND UPPER(t1.NOM_NOMBRE) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getNomNombre().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getNomNombre().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.NOM_NOMBRE IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getFecNacimiento() != null) {
			where.append(" AND t1.FEC_NACIMIENTO = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIndSexo() != null) {
			where.append(" AND UPPER(t1.IND_SEXO) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getIndSexo().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getIndSexo().toUpperCase() + "%");
			}
			where.append(" AND t1.IND_SEXO IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIsexo() != null) {
			where.append(" AND t1.ISEXO = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIndEstadoCivil() != null) {
			where.append(" AND UPPER(t1.IND_ESTADO_CIVIL) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getIndEstadoCivil().toUpperCase()
						+ "%");
			} else {
				params.add("%"
						+ m62fbp20s0s00.getIndEstadoCivil().toUpperCase() + "%");
			}
			where.append(" AND t1.IND_ESTADO_CIVIL IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIestcivi() != null) {
			where.append(" AND t1.IESTCIVI = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCpais() != null) {
			where.append(" AND t1.CPAIS = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDpais() != null) {
			where.append(" AND UPPER(t1.DPAIS) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getDpais().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getDpais().toUpperCase() + "%");
			}
			where.append(" AND t1.DPAIS IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCterrito() != null) {
			where.append(" AND t1.CTERRITO = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodProvincia() != null) {
			where.append(" AND UPPER(t1.COD_PROVINCIA) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getCodProvincia().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getCodProvincia().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.COD_PROVINCIA IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDterrito() != null) {
			where.append(" AND UPPER(t1.DTERRITO) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getDterrito().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getDterrito().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.DTERRITO IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCmunicip() != null) {
			where.append(" AND t1.CMUNICIP = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodMunicipio() != null) {
			where.append(" AND UPPER(t1.COD_MUNICIPIO) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getCodMunicipio().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getCodMunicipio().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.COD_MUNICIPIO IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDmunicip() != null) {
			where.append(" AND UPPER(t1.DMUNICIP) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getDmunicip().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getDmunicip().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.DMUNICIP IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDdirecci() != null) {
			where.append(" AND UPPER(t1.DDIRECCI) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getDdirecci().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getDdirecci().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.DDIRECCI IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getEmail() != null) {
			where.append(" AND UPPER(t1.EMAIL) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getEmail().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getEmail().toUpperCase() + "%");
			}
			where.append(" AND t1.EMAIL IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNtelefno() != null) {
			where.append(" AND t1.NTELEFNO = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNumTlfno2() != null) {
			where.append(" AND t1.NUM_TLFNO_2 = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodCalle() != null) {
			where.append(" AND UPPER(t1.COD_CALLE) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getCodCalle().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getCodCalle().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.COD_CALLE IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodPortal() != null) {
			where.append(" AND UPPER(t1.COD_PORTAL) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getCodPortal().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getCodPortal().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.COD_PORTAL IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDecSitViv() != null) {
			where.append(" AND UPPER(t1.DEC_SIT_VIV) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getDecSitViv().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getDecSitViv().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.DEC_SIT_VIV IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDecMano() != null) {
			where.append(" AND UPPER(t1.DEC_MANO) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getDecMano().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getDecMano().toUpperCase() + "%");
			}
			where.append(" AND t1.DEC_MANO IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodPostal() != null) {
			where.append(" AND UPPER(t1.COD_POSTAL) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getCodPostal().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getCodPostal().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.COD_POSTAL IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getNumCodPostal() != null) {
			where.append(" AND t1.NUM_COD_POSTAL = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getFecAlta() != null) {
			where.append(" AND t1.FEC_ALTA = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDirIpUsuario() != null) {
			where.append(" AND UPPER(t1.DIR_IP_USUARIO) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getDirIpUsuario().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getDirIpUsuario().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.DIR_IP_USUARIO IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getFehUltModif() != null) {
			where.append(" AND t1.FEH_ULT_MODIF = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodUsuUltModif() != null) {
			where.append(" AND UPPER(t1.COD_USU_ULT_MODIF) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getCodUsuUltModif().toUpperCase()
						+ "%");
			} else {
				params.add("%"
						+ m62fbp20s0s00.getCodUsuUltModif().toUpperCase() + "%");
			}
			where.append(" AND t1.COD_USU_ULT_MODIF IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIdeRegistro() != null) {
			where.append(" AND t1.IDE_REGISTRO = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getCodAplicacion() != null) {
			where.append(" AND UPPER(t1.COD_APLICACION) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getCodAplicacion().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getCodAplicacion().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.COD_APLICACION IS NOT NULL");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getIdPersona() != null) {
			where.append(" AND t1.ID_PERSONA = ?");
		}
		if (m62fbp20s0s00 != null && m62fbp20s0s00.getDesCalle() != null) {
			where.append(" AND UPPER(t1.DES_CALLE) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(m62fbp20s0s00.getDesCalle().toUpperCase() + "%");
			} else {
				params.add("%" + m62fbp20s0s00.getDesCalle().toUpperCase()
						+ "%");
			}
			where.append(" AND t1.DES_CALLE IS NOT NULL");
		}

		Map<String, Object> mapWhere = new HashMap<String, Object>();
		mapWhere.put("query", where);
		mapWhere.put("params", params);

		return mapWhere;
	}

	// CHECKSTYLE:ON CyclomaticComplexity - Generación de código de UDA

	/**
	 * StringBuilder initilization value
	 */
	public static final int STRING_BUILDER_INIT = 4096;
}
