title: Spring repository query with two table
body: <p>I have a Database with two tables :</p>
  
  <p>1) NumberEntity</p>
  
  <pre><code>|------|-------|--------|
  |  id  |numero | volume |
  |------|-------|--------|
  |  1   |    1  |   1    |
  |------|-------|--------|
  |  2   |    1  |   2    |
  |------|-------|--------|
  |  3   |    2  |   1    |
  |------|-------|--------|
  </code></pre>
  
  <p>2) ArticleEntity</p>
  
  <pre><code>|------|-------|------------|
  |  id  |Article| numbers_id |
  |------|-------|------------|
  |  5   |    7  |   1        |
  |------|-------|------------|
  |  6   |    5  |   2        |
  |------|-------|------------|
  |  7   |    6  |   3        |
  |------|-------|------------|
  </code></pre>
  
  <p>Where numbers_id is the relation with the first table.
  I would like to extract with a query through the first 
  table, the articles ordered by article desc.
  I don't know how I can do it, I started with this query:</p>
  
  <pre><code>public List&lt;NumberEntity&gt; findByVolumeAndNumero(String volume, String number);
  </code></pre>
  
  <p>I got the list of the articles but the first is the article number 7, instead I would like to extract like first article the number 5, 6 and 7.</p>
  
  <p>These are my model:</p>
  
  <pre><code>    @Entity
      public class NumberEntity implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      private String volume;
      private String numero;
      @OneToMany(mappedBy="numbers", cascade = CascadeType.ALL, orphanRemoval = true)
      private List&lt;ArticleEntity&gt; articles = new ArrayList&lt;ArticleEntity&gt;();
  </code></pre>
  
  <p>The other:</p>
  
  <pre><code> @Entity
      public class ArticleEntity implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      private String article;
      @ManyToOne
      private NumberEntity numbers;
  </code></pre>
  
  <p>So I need a query like this one (even if itsn't correct, but it's only pseudo code):</p>
  
  <pre><code>public List&lt;NumberEntity&gt; findByVolumeAndNumeroOrderByArticleDesc(String volume, String number);
  </code></pre>
  
  <p>The problem is, that I didn't understand how to join the other table with a single query using Spring</p>