3 Replies Latest reply on Feb 18, 2003 7:39 PM by jamarkha

    CMR update problem in PostCreate

    prabhackar

      i am getting an exception when trying to create a bean(patient) and then update a cmr field(location) in the ejbpostcreate method of patient bean(shown in the example below)

      location---------> patient
      1 to many (unidirectional)
      i am having only local,localHome interfaces for both the beans and location is represented only as cmr field in the patient bean

      SETUP - jboss-3.0.4_tomcat-4.1.12 on MySQL DEVELOPED using xdoclet 1.1.2/ ant 1.4

      ERROR LOG -

      ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException, causedBy:
      javax.ejb.EJBException: Data contains multiple values, but this cmr field is single valued


      CODE- (PatientBean)
      /**
      * Returns the related cmp.interfaces.Location
      *
      * @return the related cmp.interfaces.Location
      * @ejb:interface-method
      * view-type="local"
      * @ejb:relation
      * name="patient-loc"
      * role-name="patient-has-loc"
      * target-ejb="Location"
      * target-role-name="loc-has-patient"
      *
      * @jboss:relation
      * fk-constraint="true"
      * fk-column="LOC_ABBR"
      * related-pk-field="locationAbbreviation"
      *
      */
      public abstract cmp.interfaces.Location getLocation();

      /**
      *
      * @param pLocation
      **/
      public abstract void setLocation( medilis.cmp.interfaces.Location location);

      public void ejbPostCreate( PatientDC pPatient )
      {
      try{
      Context cont = new InitialContext();
      LocationHome locHome = (LocationHome)cont.lookup("cmp/Location");
      Location loc = null;
      loc = locHome.findByPrimaryKey(new LocationPK(pPatient.getLocationAbbrev()));
      setLocation(loc);
      } catch (Exception e) {
      e.printStackTrace();
      }
      }


      request to help on how to solve this problem
      (the same was earlier reported but couldnt find the solution, so iam posting it here again )


      thanks
      prabhakar