Note that there are some explanatory texts on larger screens.

plurals
  1. POLeft outer join fetch doesn't fill map collection properly (HQL)
    primarykey
    data
    text
    <p>I've got classes with mappings like this:</p> <pre><code>@Entity public class CurrencyTable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long id; @Version @Column(nullable=false) private Timestamp version; @Column(length=32, unique=true) private String refCode; @OneToMany(mappedBy="currencyTable", fetch=FetchType.LAZY, cascade = {CascadeType.ALL}) @MapKey(name="currency") private Map&lt;String, CurrencyTableRate&gt; rateMap = new HashMap&lt;String, CurrencyTableRate&gt;(); } @Entity public class CurrencyTableRate{ @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long id; @Version @Column(nullable=false) private Timestamp version; @Column(length=3) private String currency; @Basic private BigDecimal rateValue; @ManyToOne(optional=false,fetch=FetchType.LAZY) private CurrencyTable currencyTable; } </code></pre> <p>There is one row in CurrencyTable and three rows in CurrencyTableRate referring to the CurrencyTable in database.</p> <p>When I load CurrencyTable using HQL:</p> <pre><code>from CurrencyTable where refCode = :refCode </code></pre> <p>I get an entity with three entries in rateMap, but if I try this:</p> <pre><code>from CurrencyTable table left outer join fetch table.rateMap where refCode = :refCode </code></pre> <p>there is only one entry in rateMap.</p> <p>I looked on query generated by Hibernate and ran it manually - it returned three rows, as expected, so it seems to be a problem with mapping them after fetching. Has anyone encuntered such a problem? I use Hibernate version 3.2.6.ga and Oracle 10g</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload