title: JavaFX, TableView and JPA
body: <p>I'm new to JavaFX and I'm trying to refactor an old Swing application into JavaFX one.<br><br>
  I'm also using JPA (with EclipseLink implementation) to save/retrieve data.<br>
  So I've defined some POJOs annotated. <br><br>Here below my annotated POJO:</p>
  
  <pre><code>import java.io.Serializable;
  import javax.persistence.Basic;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.FetchType;
  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.Table;
  import javax.persistence.Transient;
  
  /**
   *
   * @author alex
   */
  @Entity
  @Table(name = "materiale", catalog = "elledia", schema = "")
  public class Materiale implements Serializable {
    @Transient
    private static final long serialVersionUID = 1L;
  
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
  
    @Basic(optional = false)
    @Column(name = "colata")
    private String colata;
  
    @Basic(optional = false)
    @Column(name = "dimensione")
    private String dimensione;
  
    @Basic(optional = false)
    @Column(name = "specifica")
    private String specifica;
  
    @Basic(optional = false)
    @Column(name = "unita_misura")
    private String unitaMisura;
  
    @Column(name = "version")
    private Integer version;
  
    @ManyToOne (fetch = FetchType.LAZY)
    @JoinColumn (name = "certificato_id")
    private Certificato certificato;
  
    public Materiale(Long id, String colata, String dimensione, String specifica, String unitaMisura, Certificato certificato) {
      this.id = id;
      this.colata = colata;
      this.dimensione = dimensione;
      this.specifica = specifica;
      this.unitaMisura = unitaMisura;
      this.certificato = certificato;
    }
  
    public Long getId() {
      return id;
    }
  
    public void setId(Long id) {
      Long oldId = this.id;
      this.id = id;
    }
  
    public String getColata() {
      return colata;
    }
  
    public void setColata(String colata) {
      String oldColata = this.colata;
      this.colata = colata;
    }
  
    public String getDimensione() {
      return dimensione;
    }
  
    public void setDimensione(String dimensione) {
      String oldDimensione = this.dimensione;
      this.dimensione = dimensione;
    }
  
    public String getSpecifica() {
      return specifica;
    }
  
    public void setSpecifica(String specifica) {
      String oldSpecifica = this.specifica;
      this.specifica = specifica;
    }
  
    public String getUnitaMisura() {
      return unitaMisura;
    }
  
    public void setUnitaMisura(String unitaMisura) {
      String oldUnitaMisura = this.unitaMisura;
      this.unitaMisura = unitaMisura;
    }
  
    public Integer getVersion() {
      return version;
    }
  
    public void setVersion(Integer version) {
      Integer oldVersion = this.version;
      this.version = version;
    }
  
    public Certificato getCertificato() {
      return certificato;
    }
  
    public void setCertificato(Certificato certificato) {
      Certificato oldCertificato = this.certificato;
      this.certificato = certificato;
    }
  
    @Override
    public int hashCode() {
      int hash = 0;
      hash += (id != null ? id.hashCode() : 0);
      return hash;
    }
  
    @Override
    public boolean equals(Object object) {
      // TODO: Warning - this method won't work in the case the id fields are not set
      if (!(object instanceof Materiale)) {
        return false;
      }
      Materiale other = (Materiale) object;
      if ((this.id == null &amp;&amp; other.id != null) || (this.id != null &amp;&amp; !this.id.equals(other.id))) {
        return false;
      }
      return true;
    }
  
    @Override
    public String toString() {
      return "com.alessandrodonato.elledia.certificati.gui.Materiale[ id=" + id + " ]";
    }
  
  }
  </code></pre>
  
  <p>I'm having some trouble with the TableViewcontrol:</p>
  
  <ul>
  <li>ok, I've read various post about how bind POJO to TableView.</li>
  <li>ok, I have to define an ObservableList an bind it to TableView to populate and to update it.</li>
  <li>but to define it I've to use SimpleStringProperty instead of String in my POJO properties and annotations doesn't work with this ...</li>
  </ul>
  
  <p>Any idea?</p>