<p>I have following POJOs:</p>

<pre><code>class Month {
    long id;
    String description;
    List&lt;Day&gt; days; // always contains 29, 30 or 31 elements
}

class Day {
    byte nr; // possible values are 1-31
    String info;
}
</code></pre>

<p>Is there a way to store these objects into following DB structure using JPA+Hibernate:</p>

<p>Table MONTHS:</p>

<pre>id;description;</pre>

<p>Table DAYS:</p>

<pre>id-of-month;nr-of-day;info;</pre>

<p>Any better solution for this situation?</p>

Here is one solution I found:
```
```
class Month {
    long id;
    String description;

    @CollectionOfElements(fetch = FetchType.EAGER)
    @IndexColumn(name = "nr-of-day")
    List<Day> days; // always contains 29, 30 or 31 elements
}

@Embeddable
class Day {
    byte nr; // possible values are 1-31
    String info;
}
```
```
@CollectionOfelements and @IndexColumn are Hibernate annotations. If I use @OneToMany annotation available in JPA, hibernate creates 3 tables instead of 2.
My only problem now is that Day.nr is saved twice: first as IndexColumn of the List (0-based counter) and second time as field of class Day (1-based counter).