Differences between revisions 1 and 2
Revision 1 as of 2005-03-22 05:43:34
Size: 1579
Editor: anonymous
Comment: missing edit-log entry for this revision
Revision 2 as of 2009-09-20 22:56:10
Size: 1579
Editor: localhost
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, 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

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