<?xml version="1.0" encoding="UTF-8"?>
<ns1:model xmlns:ns2="leaf.database.local.oracle" xmlns:ns1="http://www.leaf-framework.org/schema/bm"
           xmlns:f="leaf.database.features" alias="r" baseTable="sys_user_role_groups">
    <ns1:fields>
        <ns1:field name="user_role_group_id" databaseType="BIGINT" datatype="java.lang.Long"/>
        <ns1:field name="user_id" databaseType="BIGINT" datatype="java.lang.Long"/>
        <ns1:field name="role_id" databaseType="BIGINT" datatype="java.lang.Long"/>
        <ns1:field name="company_id" databaseType="BIGINT" datatype="java.lang.Long"/>
        <!--  <ns1:field name="order_seq" databaseType="NUMBER" datatype="java.lang.Long"/>-->
        <ns1:field name="company_short_name"
                   expression="(select vl.company_short_name from fnd_companies_vl vl where vl.company_id=r.company_id)"
                   forInsert="false" forUpdate="false"/>
        <ns1:field name="start_date" databaseType="DATE" datatype="java.util.Date" forInsert="true" forUpdate="true"
                   prompt="HAP_START_DATE"/>
        <ns1:field name="end_date" databaseType="DATE" datatype="java.util.Date" forInsert="true" forUpdate="true"
                   prompt="HAP_END_DATE"/>
    </ns1:fields>
    <ns1:primary-key>
        <ns1:pk-field name="user_role_group_id"/>
    </ns1:primary-key>
    <ns1:relations>
        <ns1:relation name="fc" joinType="LEFT OUTER" refModel="fnd.fnd_companies">
            <ns1:reference foreignField="company_id" localField="company_id"/>
        </ns1:relation>
        <ns1:relation name="ro" joinType="INNER" refModel="sys.sys_role">
            <ns1:reference foreignField="role_id" localField="role_id"/>
        </ns1:relation>
    </ns1:relations>
    <ns1:query-fields>
        <ns1:query-field name="user_id" queryExpression="r.user_id=${/parameter/@user_id}"/>
    </ns1:query-fields>
    <ns1:features>
        <ns2:sequence-pk/>
        <f:standard-who/>
        <f:multi-language-display/>
    </ns1:features>
    <ns1:ref-fields>
        <ns1:ref-field name="company_code" prompt="COMPANY_CODE" relationName="fc" sourceField="company_code"/>
        <ns1:ref-field name="role_code" prompt="SYS_ROLE.ROLE_CODE" relationName="ro" sourceField="role_code"/>
        <ns1:ref-field name="role_name_id" relationName="ro" sourceField="role_name_id"/>
    </ns1:ref-fields>
</ns1:model>
