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,

CaseyHelbling


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

ReferenceDescriptor (last edited 2009-09-20 22:56:20 by localhost)