<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author:   HAND技术
    $Date:     2013/12/12
    $Revision: 1.0
    $Purpose:  汽车品牌
-->
<bm:model xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="v" baseTable="HLS_CAR_BRANDS">
    <bm:fields>
        <bm:field name="brand_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BRAND_ID"/>
        <bm:field name="brand_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BRAND_CODE" prompt="HLS_CAR_BRANDS.BRAND_CODE"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="HLS_CAR_BRANDS.DESCRIPTION"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="HLS.ENABLED_FLAG"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
				select v.brand_id,
				       v.brand_code,
				       v.description,
				       v.enabled_flag
				  from hls_car_brands_vl v
				  where v.brand_id = decode(${@brand_id},null,v.brand_id,${@brand_id})
				 order by v.brand_code
    		]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter name="brand_id" input="true" inputPath="@brand_id"/>
            </bm:parameters>
        </bm:operation>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="brand_id" input="false" output="true" outputPath="@brand_id"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
        		begin
				  HLS222_SAVE_PKG.brand_manage(p_sql_type		=> 'INSERT',
				  							     p_brand_id     => ${@brand_id},
								                 p_brand_code   => ${@brand_code},
								                 p_description  => ${@description},
								                 p_enabled_flag => ${@enabled_flag},
								                 p_user_id      => ${/session/@user_id});
				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
        		begin
				  HLS222_SAVE_PKG.brand_manage(p_sql_type		=> 'UPDATE',
				  							     p_brand_id     => ${@brand_id},
								                 p_brand_code   => ${@brand_code},
								                 p_description  => ${@description},
								                 p_enabled_flag => ${@enabled_flag},
								                 p_user_id      => ${/session/@user_id});
				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
        		begin
				  HLS222_SAVE_PKG.brand_manage(p_sql_type		=> 'DELETE',
				  							     p_brand_id     => ${@brand_id},
								                 p_brand_code   => ${@brand_code},
								                 p_description  => ${@description},
								                 p_enabled_flag => ${@enabled_flag},
								                 p_user_id      => ${/session/@user_id});
				end;
        	]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="brand_id"/>
    </bm:primary-key>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="汽车品牌代码重复"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
