<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
	"https://hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    
    <query name="findAllAdvanceByOffice">
        <![CDATA[
            SELECT 
                t
            FROM Advance t 
                WHERE office = :office
                AND activeStatus = :activeStatus
            ORDER BY createdOn
        ]]>
    </query> 
    
    <query name="findAllAdvanceByOfficeBetweenDates">
        <![CDATA[
            SELECT 
                t
            FROM Advance t 
                WHERE 
                    office = :office AND
                    DATE(createdOn) >= DATE(:startDate) AND 
                    DATE(:endDate) >= DATE(createdOn)
            ORDER BY createdOn
        ]]>
    </query> 
    
    <query name="updateAdvanceByStatus">
        <![CDATA[
            UPDATE Advance
            SET 
                activeStatus = :activeStatus,
                lastUpdatedBy = :lastUpdatedBy,
                lastUpdatedOn = :lastUpdatedOn
            WHERE id = :id
        ]]>
    </query>
    
</hibernate-mapping>
