title: why is my Spring application getting wrong data from a MariaDB database?
body: <p>I'm writing a Spring application that gets data from a MariaDB server and does stuff that I haven't implemented yet because the application is getting wrong data from the server:</p>
  
  <p><a href="https://i.stack.imgur.com/w7TEV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w7TEV.png" alt="enter image description here"></a></p>
  
  <p>As you can see on the right there is the data I want to show up in my application and Spring keeps showing up in the browser the right number of occurrences but for every <code>market_id</code> just the first <code>stock_id</code> (I tried changing data, creating a new table and changing browser, the result is always the same).</p>
  
  <p>Here's the code:</p>
  
  <p>the market_stocks's spring entity</p>
  
  <pre><code>import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  
  @Entity
  public class MarketsStocks {
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
  
      private Integer marketId;
  
      private Integer stockId;
  
      public Integer getMarketId() {
          return marketId;
      }
  
      public void setMarketId(Integer marketId) {
          this.marketId = marketId;
      }
  
      public Integer getStockId() {
          return stockId;
      }
  
      public void setStockId(Integer stockId) {
          this.stockId = stockId;
      }
  }
  </code></pre>
  
  <p>and its repository</p>
  
  <pre><code>import org.springframework.data.repository.CrudRepository;
  
  public interface MarketsStocksRepository extends CrudRepository&lt;MarketsStocks, Integer&gt; {
  }
  </code></pre>
  
  <p>and here the snippet I use in the controller</p>
  
  <pre><code>@GetMapping(path = "/get-markets-stocks")
      public @ResponseBody Iterable&lt;MarketsStocks&gt; getMarketsStocks(){
          return marketsStocksRepository.findAll();
      }
  </code></pre>