title: Displaying column in tableView
body: <p>I'm trying to map and display data from tables between which there is a one-to-one relationship using <code>TableView</code> from JavaFX 8 and hibernate.</p>
  
  <p>Tables:</p>
  
  <pre><code>@Entity
  @Table(name = "CLUB")
  public class Club implements Serializable {
  
      @Id
      @Column(name = "CLUB_ID", nullable = false, unique = true)
      private int clubId;
  
      @Column(name = "NAME", nullable = false, length = 100)
      private String name;
  
      @Column(name = "CITY", length = 50)
      private String city;
  
      @OneToOne(fetch = FetchType.LAZY, mappedBy = "club", cascade = CascadeType.ALL)
      private Trainer trainer;
  
      // constructor, getters, setters
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Entity
  @Table(name = "TRAINER")
  public class Trainer implements Serializable {
  
      @Id
      @Column(name = "LICENCE_NR", nullable = false, unique = true)
      private int licenceNr;
  
      @Column(name = "NAME", nullable = false, length = 50)
      private String name;
  
      @Column(name = "SURNAME", nullable = false, length = 50)
      private String surname;
  
      @OneToOne(fetch = FetchType.LAZY)
      @PrimaryKeyJoinColumn
      private Club club;
  
      // constructor, getters, setters
  }
  </code></pre>
  
  <p><code>ClubController</code> class with <code>TableView</code>:</p>
  
  <pre><code>public class ClubController implements Initializable {
  
      ...
  
      @FXML
      private TableView&lt;Club&gt; clubTableView;
  
      @FXML
      private TableColumn&lt;Club, String&gt; nameColumn;
  
      @FXML
      private TableColumn&lt;Club, String&gt; cityColumn;
  
      @FXML
      private TableColumn&lt;Club, Integer&gt; trainerColumn;
  
      @Override
      public void initialize(URL location, ResourceBundle resources) {
          nameColumn.setCellValueFactory(new PropertyValueFactory&lt;Club, String&gt;("name"));
          cityColumn.setCellValueFactory(new PropertyValueFactory&lt;Club, String&gt;("city"));
          trainerColumn.setCellValueFactory(new Callback&lt;TableColumn.CellDataFeatures&lt;Club, Integer&gt;, ObservableValue&lt;Integer&gt;&gt;() {
              @Override
              public ObservableValue&lt;Integer&gt; call(TableColumn.CellDataFeatures&lt;Club, Integer&gt; param) {
                  return new SimpleIntegerProperty(param.getValue().getTrainer().getLicenceNr()).asObject();
              }
          });
          clubTableView.setItems(getClub());
      }
  
      private ObservableList&lt;Club&gt; getClub() {
          ObservableList&lt;Club&gt; clubList = FXCollections.observableArrayList();
          Session session = HibernateUtil.config().openSession();
          List&lt;Club&gt; cList = session.createCriteria(Club.class).list();
          clubList.addAll(cList);
          session.close();
          return clubList;
      }
  
      ...
  }
  </code></pre>
  
  <p>First two columns work correctly, but in the <code>trainerColumn</code> I have NPE. How to fix it?</p>