title: Getting a value of a field from another ejb
body: <p>I want to get a value of field in another ejb
  here's my example i want to get the value of the "CLient" from the class (Visite) and get it in "ClientVisite" in the class (DateVisite) than persist this value in the database.</p>
  
  <p>here's my code</p>
  
  <pre><code>package model.entitie;
  
  import java.io.Serializable;
  
  import java.util.Date;
  
  import javax.persistence.Column;
  import javax.persistence.ColumnResult;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.ManyToOne;
  import javax.persistence.NamedQueries;
  import javax.persistence.NamedQuery;
  import javax.persistence.SequenceGenerator;
  import javax.persistence.Temporal;
  import javax.persistence.TemporalType;
  
  import model.entitie.Visite;
  
  @Entity
  @NamedQueries({ @NamedQuery(name = "Datevisite.findAll", query = "select o from Datevisite o") })
  @SequenceGenerator(name = "DateVisite_Id_Seq_Gen", sequenceName = "DATEVISITE_SEQ", allocationSize = 1,
                     initialValue = 50)
  public class Datevisite implements Serializable {
      private static final long serialVersionUID = -341535626783197699L;
      @Id
      @Column(nullable = false, length = 4000)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DateVisite_Id_Seq_Gen")
      private String iddatevis;
      @Temporal(TemporalType.DATE)
      private Date jourvisite;
  
      @ManyToOne
      @JoinColumn(name = "VISITE_ID")
      private Visite datevisite;
      @Temporal(TemporalType.DATE)
      @Column(name = "JOURVISITEEND")
      private Date jourvisteend;
      @Column(name = "DESCRPTION")
      private String description;
      @Column(name = "CLIENTVISITE")
      private String ClientVisite;
  
  
      public void setClientVisite(String ClientVisite) {
  
          this.ClientVisite = ClientVisite;
  
      }
  
      public String getClientVisite() {
          return ClientVisite;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public String getDescription() {
          return description;
      }
  
      public void setJourvisteend(Date jourvisteend) {
          this.jourvisteend = this.jourvisite;
      }
  
      public Date getJourvisteend() {
          return jourvisteend;
      }
  
      public Datevisite() {
      }
  
      public Datevisite(String iddatevis, Date jourvisite, Visite datevisite, String ClientVisite) {
          this.iddatevis = iddatevis;
          this.jourvisite = jourvisite;
          this.datevisite = datevisite;
  
          this.ClientVisite = ClientVisite;
  
      }
  
      public String getIddatevis() {
          return iddatevis;
      }
  
      public void setIddatevis(String iddatevis) {
          this.iddatevis = iddatevis;
      }
  
      public Date getJourvisite() {
          return jourvisite;
      }
  
      public void setJourvisite(Date jourvisite) {
          this.jourvisite = jourvisite;
      }
  
  
      public Visite getDatevisite() {
          return datevisite;
      }
  
      public void setDatevisite(Visite datevisite) {
          this.datevisite = datevisite;
      }
  }
  </code></pre>
  
  <p>the Visite CLass</p>
  
  <pre><code> package model.entitie;
  
      import java.io.Serializable;
  
      import java.util.List;
  
      import javax.persistence.CascadeType;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.GenerationType;
      import javax.persistence.Id;
      import javax.persistence.NamedQueries;
      import javax.persistence.NamedQuery;
      import javax.persistence.OneToMany;
      import javax.persistence.SequenceGenerator;
  
      @Entity
      @NamedQueries({ @NamedQuery(name = "Visite.findAll", query = "select o from Visite o") })
      @SequenceGenerator(name = "Visite_Id_Seq_Gen", sequenceName = "VISITE_SEQ", allocationSize = 1, initialValue = 50)
      public class Visite implements Serializable {
          private static final long serialVersionUID = 2402539910369717472L;
          @Column(length = 4000)
          public String client;
          @Column(length = 4000)
          private String dep;
          @Id
          @Column(nullable = false, length = 4000)
          @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Visite_Id_Seq_Gen")
          private String idvisite;
          @Column(length = 4000)
          private String nbvisites;
          @OneToMany(mappedBy = "datevisite", cascade = { CascadeType.PERSIST, CascadeType.MERGE })
          private List&lt;Datevisite&gt; datevisiteList;
  
          public Visite() {
          }
  
          public Visite(String client, String dep, String idvisite, String nbvisites) {
              this.client = client;
              this.dep = dep;
              this.idvisite = idvisite;
              this.nbvisites = nbvisites;
          }
  
          public String getClient() {
              return client;
          }
  
          public void setClient(String client) {
  
              this.client = client;
          }
  
          public String getDep() {
              return dep;
          }
  
          public void setDep(String dep) {
              this.dep = dep;
          }
  
          public String getIdvisite() {
              return idvisite;
          }
  
          public void setIdvisite(String idvisite) {
              this.idvisite = idvisite;
          }
  
          public String getNbvisites() {
              return nbvisites;
          }
  
          public void setNbvisites(String nbvisites) {
              this.nbvisites = nbvisites;
          }
  
          public List&lt;Datevisite&gt; getDatevisiteList() {
              return datevisiteList;
          }
  
          public void setDatevisiteList(List&lt;Datevisite&gt; datevisiteList) {
              this.datevisiteList = datevisiteList;
          }
  
          public Datevisite addDatevisite(Datevisite datevisite) {
              getDatevisiteList().add(datevisite);
              datevisite.setDatevisite(this);
              return datevisite;
          }
  
          public Datevisite removeDatevisite(Datevisite datevisite) {
              getDatevisiteList().remove(datevisite);
              datevisite.setDatevisite(null);
              return datevisite;
          }
      }
  </code></pre>
  
  <p>and this is how i persist it</p>
  
  <pre><code>    public Datevisite persistDatevisite(Datevisite datevisite) {
      datevisite.setJourvisteend(datevisite.getJourvisite());
  
      em.persist(datevisite);
      return datevisite;
  }
  </code></pre>