Hi all,
I have a one-to-many relationship between Wachlist class and Profile class
(a watchlist contains one or more profiles)
the mapping is like that :
Watchlist.hbm.xml
<map name="profiles" inverse="true"
cascade="all-delete-orphan">
<key column="WATCHLIST_ID" />
<map-key column="STOCK_ID" type="long" />
<one-to-many class="Profile" />
</map>
Profile.hbm.xml
<many-to-one name="watchlist" class="Watchlist" column="WATCHLIST_ID" not-null="true" unique-key="WATCHLIST_UNIQUE" cascade="lock"/>
in code i want to add a profile to a watchlist so i worte the following line
Code:
watchlist.getProfiles().put(stock.getId(),profile);
when using hibernate 3.1 CR1 the above line of code initialize the map and add the new profile successfully.
But when using hibernate 3.2.0 GA the above line of code just
INITAILIZE the map and ignore the put method
to overcome this, i explicitly initialize the map
Code:
Hibernate.initialize(watchlist.getProfiles());
watchlist.getProfiles().put(stock.getId(),profile);
So I wonder if there any problem initializing the map and putting a new element at the same time when using hibernate hibernate 3.2.0 GA?
Thanks