<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-3-8 下午4:07:21  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:e="leaf.service.exception" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HLS_LEASE_ORGANIZATION">
    <bm:fields>
        <bm:field name="lease_organization" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_ORGANIZATION" prompt="HLS.LEASE_ORGANIZATIONS_CODE"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="HLS.LEASE_ORGANIZATION_NAME"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="HLS.ENABLED_FLAG"/>
        <bm:field name="unit_id" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" physicalName="UNIT_ID"/>
        <bm:field name="unit_name" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" physicalName="UNIT_NAME"/>
        <bm:field name="ref_v01" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V01" prompt="HLS_LEASE_ORGANIZATION.REF_V01"/>
        <bm:field name="ref_v02" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V02" prompt="HLS_LEASE_ORGANIZATION.REF_V02"/>
        <bm:field name="ref_v03" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V03" prompt="HLS_LEASE_ORGANIZATION.REF_V03"/>
        <bm:field name="ref_v04" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V04" prompt="HLS_LEASE_ORGANIZATION.REF_V04"/>
        <bm:field name="ref_v05" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V05" prompt="HLS_LEASE_ORGANIZATION.REF_V05"/>
        <bm:field name="ref_n01" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N01" prompt="HLS_LEASE_ORGANIZATION.REF_N01"/>
        <bm:field name="ref_n01_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="ref_n02" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N02" prompt="HLS_LEASE_ORGANIZATION.REF_N02"/>
        <bm:field name="ref_n03" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N03" prompt="HLS_LEASE_ORGANIZATION.REF_N03"/>
        <bm:field name="ref_n04" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N04" prompt="HLS_LEASE_ORGANIZATION.REF_N04"/>
        <bm:field name="ref_n05" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N05" prompt="HLS_LEASE_ORGANIZATION.REF_N05"/>
        <bm:field name="ref_d01" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D01" prompt="HLS_LEASE_ORGANIZATION.REF_D01"/>
        <bm:field name="ref_d02" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D02" prompt="HLS_LEASE_ORGANIZATION.REF_D02"/>
        <bm:field name="ref_d03" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D03" prompt="HLS_LEASE_ORGANIZATION.REF_D03"/>
        <bm:field name="ref_d04" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D04" prompt="HLS_LEASE_ORGANIZATION.REF_D04"/>
        <bm:field name="ref_d05" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D05" prompt="HLS_LEASE_ORGANIZATION.REF_D05"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			select t1.lease_organization,
				       t1.description,
				       t1.enabled_flag,
				       (select oa.unit_id
				          from hls_lease_org_assign oa
				         where oa.lease_organization = t1.lease_organization
				           and oa.company_id = ${@company_id}) as unit_id,
				       (select eou.unit_name
				          from hls_lease_org_assign oa, exp_org_unit_v eou
				         where oa.lease_organization = t1.lease_organization
				           and oa.company_id = ${@company_id}
				           and oa.unit_id = eou.unit_id) as unit_name,
				       t1.ref_v01,
				       t1.ref_v02,
				       t1.ref_v03,
				       t1.ref_v04,
				       t1.ref_v05,
				       t1.ref_n01,
				       (select e.name
				          from exp_employees e
				         where e.employee_id = t1.ref_n01) as ref_n01_desc,
				       t1.ref_n02,
				       t1.ref_n03,
				       t1.ref_n04,
				       t1.ref_n05,
				       t1.ref_d01,
				       t1.ref_d02,
				       t1.ref_d03,
				       t1.ref_d04,
				       t1.ref_d05
				  from hls_lease_organization t1
				 #WHERE_CLAUSE#
				 order by lease_organization
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="lease_organization"/>
    </bm:primary-key>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="HLS101.HLS_LEASE_ORGANIZATION.CODE_UNIQUE_ERROR"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
