<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-10-12 下午07:05:39  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    d.contract_id,
                    d.contract_number,
                    d.contract_name,
                    d.five_class_code,
                    (SELECT
                        fcc.description
                    FROM
                        rsc_five_class_code fcc
                    WHERE
                        fcc.five_class_code = d.five_class_code
                    ) five_class_name
                FROM
                    con_contract d
                WHERE
                    EXISTS
                    (SELECT
                        1
                    FROM
                        con_contract_bp b
                    WHERE
                        b.contract_id = d.contract_id AND
                        b.bp_id       =
                        (SELECT
                            c.bp_id_tenant
                        FROM
                            con_contract c
                        WHERE
                            c.contract_id  = ${@contract_id} AND
                            c.contract_id <> d.contract_id
                        )
                    )
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NAME"/>
        <bm:field name="five_class_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FIVE_CLASS_CODE"/>
        <bm:field name="five_class_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FIVE_CLASS_NAME"/>
    </bm:fields>
</bm:model>
