<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from (
                SELECT
                    t.con_mortgage_id,
                    t.contract_id,
                    t.mortgage_id,
                    t.mortgage_name,
                    t.bp_id_mortgagor,
                    t.bp_id_mortgagor_n,
                    t.mortgage_type,
                    t.mortgage_type_n,
                    t.mortgage_ast_classfication,
                    t.mortgage_ast_classfication_n,
                    t.mortgage_asset_detail,
                    t.mortgage_asset_detail_n
                FROM
                    con_contract_mortgage_lv t) t1
                    #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
            begin
                INSERT
                INTO
                    con_contract_mortgage
                    (
                        con_mortgage_id,
                        contract_id,
                        mortgage_name,
                        bp_id_mortgagor,
                        mortgage_type,
                        mortgage_ast_classfication,
                        mortgage_asset_detail
                    )
                    VALUES
                    (
                        con_contract_mortgage_s.nextval,
                        ${@contract_id},
                        ${@mortgage_name},
                        ${@bp_id_mortgagor},
                        ${@mortgage_type},
                        ${@mortgage_ast_classfication},
                        ${@mortgage_asset_detail}
                    );
                  end;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    UPDATE
                        con_contract_mortgage t
                    SET
                        t.mortgage_name             =${@mortgage_name},
                        t.bp_id_mortgagor           =${@bp_id_mortgagor},
                        t.mortgage_type             =${@mortgage_type},
                        t.mortgage_ast_classfication=${@mortgage_ast_classfication},
                        t.mortgage_asset_detail     =${@mortgage_asset_detail}
                    WHERE
                        t.con_mortgage_id=${@con_mortgage_id};
                END;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
                BEGIN
                    delete from 
                        con_contract_mortgage t
                    where
                        t.con_mortgage_id=${@con_mortgage_id};
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="(t1.contract_id =${@contract_id})"/>
    </bm:data-filters>
</bm:model>
