0 Replies Latest reply on Jun 9, 2005 4:37 AM by natanasov

    A problem with EJB entities

    natanasov

      Hello

      I have a problem with Entity beans.
      There are two entity beans MMOElement and MMOTranslation.
      The beans are persisted in different tables and their primary keys are composite keys. They keys are mapped to columns with different names in the tables. The classes have a common behavior that I extract in an abstract class.

      The problem rises when I call EntityManager.find() method. The framework make a two calls to setPk() method. The first call set the correct primary key but the second call set null. The following code only is a part of the application

      public abstract class ObjectPK{
      ...
      }
      
      public class MMOElementPK extends ObjectPK{
      ...
      }
      
      public abstract class ModelingObject implements Serializable{
      ...
       @Transient
       public abstract ObjectPK getPk();
      ...
      }
      
      @Entity
      @Table(name = "DICT_OMM_CONTENTS")
      public class MMOElement extends ModelingObject{
      ?
      @EmbeddedId( {
       @AttributeOverride(name = "objectCompany",
       column = @Column(name = "ID_COMPANY")),
       @AttributeOverride(name = "objectId",
       column = @Column(name = "ID_OMM")),
       @AttributeOverride(name = "seqOrder")
       })
       public MMOElementPK getPk()
       {
       return pk;
       }
      ?
      }