title: Hibernate retuns object not list
body: <p>When I execute a search using Hibernate I receive</p>
  
  <blockquote>
    <p>entities.Tbphonebook@(number and letter combination)</p>
  </blockquote>
  
  <p>in my console log instead of a list of all items held.  If I change my system out print to</p>
  
  <pre><code>system.out.println(person.getLastname)
  </code></pre>
  
  <p>I see what last names are held in the objects that were returned.  I want to search a first name and have first name, Last name, area code, and phone number returned. This may be because I am using depreciated language but I am having a hard time figuring out what the new version should be. I have tried to suppress the warnings but that didn't fix the problem.</p>
  
  <p>Thank you for your help.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>      &lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;head&gt;
      &lt;meta charset="ISO-8859-1"&gt;
      &lt;title&gt;Add contact to Phone Book&lt;/title&gt;
      &lt;h1&gt;Add contact to Phone Book&lt;/h1&gt;
      &lt;/head&gt;
      &lt;body&gt;
        &lt;form name="submitInfo" method="get" action="AddEntryServlet"&gt;
              First Name: &lt;input type="text" name="firstName"/&gt; &lt;br/&gt;
              &lt;br/&gt;
              Last Name: &lt;input type="text" name="lastName"/&gt; &lt;br/&gt;
              &lt;br/&gt;
              Area Code: &lt;input type="number" name="areaCode"/&gt; &lt;br/&gt;
              &lt;br/&gt;
              Phone Number: &lt;input type="number" name="phoneNumber"/&gt; &lt;br/&gt;
              &lt;br/&gt;
              &lt;input type="submit" value="Submit" /&gt;
  
          &lt;/form&gt;
      &lt;/body&gt;
      &lt;h1&gt;Search for Contact in Phone Book&lt;/h1&gt;
      &lt;body&gt;
        &lt;form name="searchInfo" method="get" action="SearchServlet"&gt;
              Search First Name: &lt;input type="text" name="searchFirstName"/&gt; &lt;br/&gt;
              &lt;br/&gt;
              Search Last Name: &lt;input type="text" name="searchLastName"/&gt; &lt;br/&gt;
              &lt;br/&gt;
              &lt;input type="submit" name="action" value="search" /&gt;
              
              &lt;/form&gt;
      &lt;/body&gt;
      &lt;/html&gt;
      &lt;br&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>SQL map file Tbphonebook</strong></p>
  
  <pre><code>    package entities;
  // Generated Dec 13, 2017 10:03:41 PM by Hibernate Tools 5.2.6.Final
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  /**
   * Tbphonebook generated by hbm2java
   */
  @Entity
  @Table(name = "tbphonebook", schema = "public")
  public class Tbphonebook implements java.io.Serializable {
  
  
  private int id;
  private String firstname;
  private String lastname;
  private Integer areacode;
  private Integer phonenumber;
  
  public Tbphonebook() {
  }
  
  public Tbphonebook(int id) {
      this.id = id;
  }
  
  public Tbphonebook(int id, String firstname, String lastname, Integer areacode, Integer phonenumber) {
      this.id = id;
      this.firstname = firstname;
      this.lastname = lastname;
      this.areacode = areacode;
      this.phonenumber = phonenumber;
  }
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "id", unique = true, nullable = false)
  public int getId() {
      return this.id;
  }
  
  public void setId(int id) {
      this.id = id;
  }
  
  @Column(name = "firstname")
  public String getFirstname() {
      return this.firstname;
  }
  
  public void setFirstname(String firstname) {
      this.firstname = firstname;
  }
  
  @Column(name = "lastname", length = 30)
  public String getLastname() {
      return this.lastname; 
  }
  
  public void setLastname(String lastname) {
      this.lastname = lastname;
  }
  
  @Column(name = "areacode")
  public Integer getAreacode() {
      return this.areacode;
  }
  
  public void setAreacode(Integer areacode) {
      this.areacode = areacode;
  }
  
  @Column(name = "phonenumber")
  public Integer getPhonenumber() {
      return this.phonenumber;
  }
  
  public void setPhonenumber(Integer phonenumber) {
      this.phonenumber = phonenumber;
    }
  
  }
  </code></pre>
  
  <p><strong>Search Servlet</strong></p>
  
  <pre><code>import java.io.IOException;
  import java.util.List;
  
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.hibernate.Query;
  import org.hibernate.Session;
  
  import entities.Tbphonebook;
  import util.HibernateUtil;
  
  /**
   * Servlet implementation class SearchServlet
   */
  
  @WebServlet("/SearchServlet")
  public class SearchServlet extends HttpServlet {
  private static final long serialVersionUID = 1L;
  
  /**
   * @see HttpServlet#HttpServlet()
   */
  public SearchServlet() {
      super();
      // TODO Auto-generated constructor stub
  }
  
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  @SuppressWarnings({ "deprecation", "unchecked" })
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      response.getWriter().append("Served at: ").append(request.getContextPath());
      Session session = HibernateUtil.getSessionFactory().openSession();
      session.beginTransaction();
  
      String firstName = request.getParameter("searchFirstName");
      // String lastName = request.getParameter("searchLastName");
  
      @SuppressWarnings("rawtypes")
      Query query = session.createQuery("from Tbphonebook where firstname = ?");
  
      query.setParameter(0, firstName);
  
  
      List&lt;Tbphonebook&gt; persons = (List&lt;Tbphonebook&gt;) query.getResultList();
  
  
      for(Tbphonebook person : persons)
          System.out.println(person);
      //response.getWriter().append("match" + person);
      session.getTransaction().commit();
      session.close();
  
  }
  
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      doGet(request, response);
    }
  
  }
  </code></pre>