只需从userloginmodel入手
其model定义是
<entity entity-name="UserLogin"
package-name="org.ofbiz.security.login"
title="User Login Entity">
<field name="userLoginId" type="id-vlong-ne"></field>
<field name="currentPassword" type="short-varchar"></field>
<field name="passwordHint" type="description"></field>
<field name="isSystem" type="indicator"></field>
<field name="enabled" type="indicator"></field>
<field name="hasLoggedOut" type="indicator"></field>
<field name="requirePasswordChange" type="indicator"></field>
<field name="lastCurrencyUom" type="id"></field>
<field name="lastLocale" type="very-short"></field>
<field name="lastTimeZone" type="id-long"></field>
<field name="disabledDateTime" type="date-time"></field>
<field name="successiveFailedLogins" type="numeric"></field>
<field name="externalAuthId" type="id-vlong-ne">
<description>For use with external authentication; the userLdapDn should be replaced with this</description>
</field>
<field name="userLdapDn" type="id-vlong-ne">
<description>The user's LDAP Distinguished Name - used for LDAP authentication</description>
</field>
<prim-key field="userLoginId"/>
</entity>
这里是在framework\security\entitydef下面的定义,无关紧要,直接去applications\party\entitymodel.xml找到
<extend-entity entity-name="UserLogin">
<field name="partyId" type="id"></field>
<relation type="one" fk-name="USER_PARTY" rel-entity-name="Party">
<key-map field-name="partyId"/>
</relation>
<relation type="one-nofk" rel-entity-name="Person">
<key-map field-name="partyId"/>
</relation>
<relation type="one-nofk" rel-entity-name="PartyGroup">
<key-map field-name="partyId"/>
</relation>
</extend-entity>
可以看到改内容对UserLogin进行的扩展。提供了更多信息。
首先看到它和三张表Party Person PartyGroup都有关系。
到数据库查看第一张表Party ,定义如下
[img]http://dl.iteye.com/upload/attachment/544481/d5fb3432-43ee-31b8-885b-7fa9eca30155.png[/img]
UserLogin首先关联到表Party的PARTY_ID。找到Party后,由PARTY_TYPE_ID确定它是Person还是PartyGroup了。
其次,需要注意的是四张表的Party的PARTY_ID都是一样的数据类型VARCHAR(20)。
也就是说UserLogin的PARTY_ID能查到Party,然后根据PARTY_TYPE_ID决定查得是Person表还是PartyGroup表。
然后决定后,就可以去查实际的表了。
查的方式还是根据UserLogin的PARTY_ID和Person或者PartyGroup表的PARTY_ID相同的那条数据。
其model定义是
<entity entity-name="UserLogin"
package-name="org.ofbiz.security.login"
title="User Login Entity">
<field name="userLoginId" type="id-vlong-ne"></field>
<field name="currentPassword" type="short-varchar"></field>
<field name="passwordHint" type="description"></field>
<field name="isSystem" type="indicator"></field>
<field name="enabled" type="indicator"></field>
<field name="hasLoggedOut" type="indicator"></field>
<field name="requirePasswordChange" type="indicator"></field>
<field name="lastCurrencyUom" type="id"></field>
<field name="lastLocale" type="very-short"></field>
<field name="lastTimeZone" type="id-long"></field>
<field name="disabledDateTime" type="date-time"></field>
<field name="successiveFailedLogins" type="numeric"></field>
<field name="externalAuthId" type="id-vlong-ne">
<description>For use with external authentication; the userLdapDn should be replaced with this</description>
</field>
<field name="userLdapDn" type="id-vlong-ne">
<description>The user's LDAP Distinguished Name - used for LDAP authentication</description>
</field>
<prim-key field="userLoginId"/>
</entity>
这里是在framework\security\entitydef下面的定义,无关紧要,直接去applications\party\entitymodel.xml找到
<extend-entity entity-name="UserLogin">
<field name="partyId" type="id"></field>
<relation type="one" fk-name="USER_PARTY" rel-entity-name="Party">
<key-map field-name="partyId"/>
</relation>
<relation type="one-nofk" rel-entity-name="Person">
<key-map field-name="partyId"/>
</relation>
<relation type="one-nofk" rel-entity-name="PartyGroup">
<key-map field-name="partyId"/>
</relation>
</extend-entity>
可以看到改内容对UserLogin进行的扩展。提供了更多信息。
首先看到它和三张表Party Person PartyGroup都有关系。
到数据库查看第一张表Party ,定义如下
[img]http://dl.iteye.com/upload/attachment/544481/d5fb3432-43ee-31b8-885b-7fa9eca30155.png[/img]
UserLogin首先关联到表Party的PARTY_ID。找到Party后,由PARTY_TYPE_ID确定它是Person还是PartyGroup了。
其次,需要注意的是四张表的Party的PARTY_ID都是一样的数据类型VARCHAR(20)。
也就是说UserLogin的PARTY_ID能查到Party,然后根据PARTY_TYPE_ID决定查得是Person表还是PartyGroup表。
然后决定后,就可以去查实际的表了。
查的方式还是根据UserLogin的PARTY_ID和Person或者PartyGroup表的PARTY_ID相同的那条数据。