title: Spring MVC/Hibernate/mySQL "read" is always null
body: <p>I've read through a few posts and I am not able to figure out what I am doing wrong here. </p>
  
  <p>I have a simple Stock Quote web app that reads from a mySQL database. For now, all I am trying to accomplish is a "search" (read) of a symbol from the DB. </p>
  
  <p>I can hard-code the symbol and it works as it is suppose to, however when I type a symbol into the actual field, it is read as 'null' and nothing happens. I'm new to this and only started coding in May, so I know I am most likely just overlooking something. </p>
  
  <p>Any help will be appreciated, as I have been working on this for about a week and I just can't figure out what's going on. I'm going to school online so I don't have a lot of people to reach out to! Thanks! </p>
  
  <p>Controller: </p>
  
  <pre><code>@Controller
  @RequestMapping("/stockQuote")
  public class StockQuoteController {
  
  // inject StockService
  @Autowired
  private StockService stockQuoteService;
  
  @RequestMapping("/list")
  public String listStocks (Model theModel) throws IOException {
  
      // get the quotes form the dao
      List&lt;StockQuote&gt; theQuote = stockQuoteService.getStockQuotes();
  
      // add the customers to the model
      theModel.addAttribute("stockQuote", theQuote);
      return "list-stocks";
  
  }
  
  
  @GetMapping("/index")
  public String setupForm(Map&lt;String, Object&gt; map){
      StockQuote stockQuote = new StockQuote();
      map.put("student", stockQuote);
      map.put("studentList", stockQuoteService.getStockQuotes());
      return "search";
  }
  
  @PostMapping("/doSearch")
  public String doActions(@ModelAttribute StockQuote stockQuote, Model theModel, String symbol) throws IOException {
  
      List&lt;StockQuote&gt; theQuote = stockQuoteService.searchQuotes(symbol);
  
      theModel.addAttribute("stockQuote", theQuote);
  
      return "search";
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>StockQuoteDAOimpl: </p>
  
  <pre><code>@Repository
  public class StockQuoteDAOimpl implements StockQuoteDAO {
  //I need to inject the session factory
  @Autowired
  private SessionFactory sessionFactory;
  
  
  
  @Override
  public List&lt;StockQuote&gt; getStockQuote() {
  
      // I need to get the current hibernate session
      Session currentSession = sessionFactory.getCurrentSession();
  
      // create a query
  
      Query&lt;StockQuote&gt; theQuery = currentSession.createQuery("from StockQuote order by symbol", StockQuote.class);
  
      // execute query and get result list
      List&lt;StockQuote&gt; stockQuotes = theQuery.getResultList();
  
      // return list of stock quotes
  
      return stockQuotes;
  }
  
  @Override
  public List&lt;StockQuote&gt; searchQuotes(String symbol) {
  
  
   Session currentSession = sessionFactory.getCurrentSession();
   sessionFactory.openSession();
  
   Query&lt;StockQuote&gt; theQuery = currentSession.createQuery("from StockQuote where symbol = '" + symbol + "'",
              StockQuote.class);
  
      List&lt;StockQuote&gt; stockQuotes = theQuery.getResultList();
  
  
      return stockQuotes;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>StockQuoteServiceImpl: </p>
  
  <pre><code>@Service
  @EnableTransactionManagement
  public class StockQuoteServiceImpl implements StockService {
  
  @Autowired // injecting our StockQuoteDAO
  private StockQuoteDAO stockQuoteDAO;
  
  @Override
  @Transactional // handles DB transactions at the service level
  public List&lt;StockQuote&gt; getStockQuotes() {
      return stockQuoteDAO.getStockQuote();
  }
  
  @Override
  @Transactional
  public List&lt;StockQuote&gt; searchQuotes(String symbol) {
      return stockQuoteDAO.searchQuotes(symbol);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>StockQuote DAO: 
      @Entity
      @Indexed
      @EnableTransactionManagement
      @Table(name = "stock_quotes")
      public class StockQuote extends StockData {</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "id")
  private int id;
  
  @Column(name = "price", nullable = false, length = 20)
  @org.hibernate.search.annotations.Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
  private BigDecimal price;
  
  @Column(name = "date", nullable = false, length = 20)
  @org.hibernate.search.annotations.Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
  private Date date;
  
  @Column(name = "symbol", nullable = false, length = 20)
  @org.hibernate.search.annotations.Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
  private String symbol;
  
  
  public StockQuote() {}
  
  public StockQuote(String symbol, BigDecimal price, Date date) {
      super();
      this.price = price;
      this.date = date;
      this.symbol = symbol;
  }
  
  public int getId() {
      return id;
  }
  
  public void setId(int id) {
      this.id = id;
  }
  
  public BigDecimal getPrice() {
      return price;
  }
  
  public void setPrice(BigDecimal price) {
      this.price = price;
  }
  
  public Date getDate() {
      return date;
  }
  
  public void setDate(Date date) {
      this.date = date;
  }
  
  public String getSymbol() {
      return symbol;
  }
  
  public void setSymbol(String symbol) {
      this.symbol = symbol;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Search.jsp: </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Stock Quote Query&lt;/title&gt;
  
  &lt;link type="text/css"
        rel="stylesheet"
        href="${pageContext.request.contextPath}/resources/css/style.css"&gt;
  
  &lt;link type="text/css"
        rel="stylesheet"
        href="${pageContext.request.contextPath}/resources/css/add-customer-style.css"&gt;
  </code></pre>
  
  <p>
  </p>
  
  <pre><code>&lt;div id="wrapper"&gt;
  &lt;div id="header"&gt;
      &lt;h2&gt;Easy Quote Query&lt;/h2&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="container"&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;h2&gt;Search for Stock&lt;/h2&gt;
  
    &lt;form:form action="doSearch" method="post" 
   modelAttribute="stockQuote"&gt;
  
      Symbol: &lt;input type="search" name="searchText"/&gt;&lt;br/&gt;
  
      &lt;br&gt;&lt;br&gt;
  
      &lt;input type="submit" name="action" value="search"/&gt;
  
  
  
  &lt;/form:form&gt;
  
  &lt;br&gt;&lt;br&gt;
  
  &lt;h2&gt;Found Stocks&lt;/h2&gt;
  &lt;table border="1"&gt;
      &lt;th&gt;Symbol&lt;/th&gt;
      &lt;th&gt;Price&lt;/th&gt;
      &lt;th&gt;Date&lt;/th&gt;
      &lt;c:forEach items="${stockQuote}" var="stock"&gt;
          &lt;tr&gt;
              &lt;td&gt;${stock.symbol}&lt;/td&gt;
              &lt;td&gt;${stock.price}&lt;/td&gt;
              &lt;td&gt;${stock.date}&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/c:forEach&gt;
  &lt;/table&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>