<?xml version="1.0" encoding="UTF-8"?>
<!--
Arrebol Consultancy copyright.

This code belongs to Arrebol Consultancy
its use, redistribution or modification are prohibited 
without written authorization from Arrebol Consultancy.
-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
	"https://hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    
    <query name="findPersonByPersonTypeAndRouteAndOffice">
        <![CDATA[
            SELECT 
                person
            FROM 
                AdministrationPersonSerchView person
            WHERE 
                person.peopleType IN (:peopleType, 'BOTH') AND
                person.idRoute = :idRoute AND
                person.idOffice = :idOffice
            ORDER BY person.personSearch
        ]]>
    </query>
    
    <query name="likePersonNameInPersonTypeInRoutesAndOffice">
        <![CDATA[
            SELECT 
                person
            FROM 
                AdministrationPersonSerchView person
            WHERE 
                person.personSearch LIKE :personSearch AND
                person.peopleType IN (:peopleType, 'BOTH') AND
                person.idRoute IN (:idRoute) AND
                person.idOffice = :idOffice
            ORDER BY person.personSearch
        ]]>
    </query>
    
    <query name="likePersonNameInPersonTypeAllRoutesByOffice">
        <![CDATA[
            SELECT 
                person
            FROM 
                AdministrationPersonSerchView person
            WHERE 
                person.personSearch LIKE :personSearch AND
                person.peopleType IN (:peopleType, 'BOTH') AND
                person.idOffice = :idOffice
            ORDER BY person.personSearch
        ]]>
    </query>
    
</hibernate-mapping>