It seemed like a good idea at the time. Why hard code all those SQL statements when you can just soft code them in a configuration file? That way, the data model can be changed without the other layers needing to know about it. It's brilliant!

Although Jan Fabry wasn't around for the "let's put all our queries in a separate file" decision, he was around for support, which was long after all the decision-makers moved on to bigger and better things. "In practice," he wrote, "the idea didn't work so well. Especially when the name, the comment and the code seem to disagree about what to do.

    <query name="delete_authorization">
        <comment>insert new local authorization (FR)</comment>
        <sql><![CDATA[
SELECT
    AUTH.AUTH_ID "id",
    AUTH.CODE "code",
    AUTH.IS_LOCAL "is_local",
    AUTH.CONTACT "contact",
    ALOC.NAME "name",
    ALOC.ERP_DESCRIPTION "erp_description",
    ALOC.ADDITIONAL_GUIDELINES "additional_guidelines",
    LOCA.CODE "locale_code"
FROM S071_AUTHORIZATION AUTH
    LEFT JOIN S071_AUTHORIZATION_LOCALE ALOC ON (AUTH.AUTH_ID = ALOC.AUTH_ID)
    LEFT JOIN S071_LOCALE LOCA ON (ALOC.LOCA_ID = LOCA.LOCA_ID)
WHERE AUTH.AUTH_ID = :auth_id
        ]]></sql>
    </query>