0 Replies Latest reply on Nov 23, 2002 12:47 PM by arnaud jamin

    how to encapsulte relation attributes in DataObject

    arnaud jamin Newbie

      Hello, i'm using xdoclet and CMP2.0
      I'd like to know, if it's possible to have in an ObjectData the getter and setter of a relation attribute.

      I have the following relation in an entity called "Project", which attach a director to a project:

      * @ejb:interface-method view-type="local"
      * @ejb.relation
      * name="director-project"
      * role-name="project-has-director"
      * @jboss.relation-mapping style="foreign-key"
      * @jboss.relation
      * fk-constraint="true"
      * fk-column="director_fk"
      * related-pk-field="id"
      public abstract UserLocal getDirector();

      I'd like my ProjectData to contain the following methods :
      Integer getDirectorId(){..}
      void setDirectorId(Integer Director){..}

      So when I call the FindByPrimaryKey methods on project, the returned projetData would contain the id of the director attached to the project.

      I tried to add this methods in my entity:

      * @ejb.interface-method view-type="local"
      * @ejb:persistent-field
      * @ejb.persistence column-name="director_fk"
      public abstract Integer getDirectorIdFk();

      * @ejb.interface-method view-type="local"
      public abstract void setDirectorIdFk(Integer directorIdFk);

      Now the ObjectData contain the getter and the setter, but its create another column in my table called "directorIdFK". So it doesn't use the table "director_fk"