|
⇤ ← Revision 1 as of 2004-02-29 13:56:54
Size: 1549
Comment: Converted from Usemod wiki.
|
← Revision 2 as of 2009-09-20 22:56:20 ⇥
Size: 1549
Comment: converted to 1.6 markup
|
| No differences found! | |
QUESTION: If i have a Person associated 1:1 with an Account and it is modeled in the db such that the person table has a account_id... is there a way to not require the field descriptor of accountId?
<class-descriptor class="com.gintek.domain.Person" table="person">
<field-descriptor name="accountId" column="account_id" jdbc-type="INTEGER"/>
<reference-descriptor name="account" class-ref="com.gintek.domain.Account" auto-update="true">
<foreignkey field-ref="accountId">
</reference-descriptor>
</class-descriptor>I dont want to have a random "accountId" in my Person class when i already have a reference to the Account object that contains the "accountId".
public class Person extends DomainObject {
// i dont want to have this accountId here
private long accountId;
private Account account;
// etc, etc, etc
}Thanks,
ANSWER:
Your class doesn't need to actually have an "accountId" field. You just need to add the access="anonymous" attribute to your field-descriptor tag.
Make it look like this:
<class-descriptor class="com.gintek.domain.Person" table="person">
<field-descriptor name="accountId" column="account_id" jdbc-type="INTEGER" access="anonymous"/>
<reference-descriptor name="account" class-ref="com.gintek.domain.Account" auto-update="true">
<foreignkey field-ref="accountId">
</reference-descriptor>
</class-descriptor>-- RyanDlugosz