-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Left outer join fetch doesn't fill map collection properly.
PostPosted: Wed May 27, 2009 8:18 am 
Newbie

Joined: Wed May 27, 2009 7:01 am
Posts: 2
Hi

I've got classes with mappings like this:
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<String, CurrencyTableRate> rateMap = new HashMap<String, CurrencyTableRate>();
}

@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;
}


There is one row in CurrencyTable and three rows in CurrencyTableRate referring to the CurrencyTable in database.
When I load CurrencyTable using HQL:
Code:
from CurrencyTable where refCode = :refCode

I get an entity with three entries in rateMap, but if I try this:
Code:
from CurrencyTable table left outer join fetch table.rateMap where refCode = :refCode

there is only one entry in rateMap.

I looked on query generated by Hibernate and run them manually - it returns 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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.