title: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled or you need to define rowKey attribute
body: <p>I had this exception in selecting a single row:</p>
  
  <pre><code> javax.faces.FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled or you need to define rowKey attribute
  </code></pre>
  
  <p>Here is the table:</p>
  
  <pre><code>&lt;h:form&gt;
      &lt;p:dataTable id="books" value="#{myCardBean.booksList}" var="book" selectionMode="single"
                   selection="#{myCardBean.selectedBook}" rowKey="book.id"&gt;
  
          &lt;p:ajax event="rowSelect" listener="#{myCardBean.onRowSelect}"/&gt;
          &lt;p:ajax event="rowUnselect" listener="#{myCardBean.onRowUnselect}"/&gt;
  
          &lt;p:column&gt;
              &lt;f:facet name="header"&gt;Book ID&lt;/f:facet&gt;
              &lt;h:outputText value="#{book.id}"/&gt;
          &lt;/p:column&gt;
          &lt;p:column&gt;
              &lt;f:facet name="header"&gt;Title&lt;/f:facet&gt;
              &lt;h:outputText value="#{book.title}"/&gt;
          &lt;/p:column&gt;
      &lt;/p:dataTable&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>And this is <code>myCardBean</code> :</p>
  
  <pre><code>@ManagedBean
  @ViewScoped
  @Component
  public class MyCardBean implements Serializable {
  
  @Autowired
  private BookDao bookDao;
  private List&lt;Book&gt; booksList;
  private Book selectedBook;
  
  @PostConstruct
  public void init() {
      userCard();
  }
  
  @Transactional
  public List&lt;Book&gt; userCard() {
      booksList = bookDao.findAllBooks();
      System.out.println("all Books size: " + booksList.size() + " books list type: " + booksList); // 3 , list of Object
  
      return booksList;
  }
  
  public void onRowSelect(SelectEvent event) {
      System.out.println("row selected, " + event.getObject());
  }
  
  public void onRowUnselect(UnselectEvent event) {
  }
  //getter/setter for selectedBook and bookList
  </code></pre>
  
  <p>And this is <code>Book</code> model class:</p>
  
  <pre><code>public class Book implements Serializable {
  
  @Id
  @GeneratedValue
  private Integer id;
  @Column(nullable = false)
  private String title;
  //...
  </code></pre>
  
  <p>I defined <code>rowKey</code> and <code>Selection</code> and <code>selectionMode</code> in datatable</p>
  
  <p>I have no idea why should i got this error?!</p>
  
  <p>should <code>id</code> be <code>String</code> instead of <code>Integer</code>?</p>