Note that there are some explanatory texts on larger screens.

plurals
  1. POhibernate @CollectionOfElements not persisted
    primarykey
    data
    text
    <p>HI,</p> <p>I am using Hibernate with plenty of satisfaction so far. Lately it seems that I am not able to persist a @CollectionOfElements using annotation.</p> <p>I am saving an object of class Estate which contains a Map of RoomGroups like here:</p> <pre><code>@javax.persistence.MapKey(name = "code") @Cascade(value = {CascadeType.DELETE_ORPHAN, CascadeType.SAVE_UPDATE}) @OneToMany(mappedBy = "estate") @org.hibernate.annotations.OrderBy(clause = "code ASC") private Map&lt;String, RoomsGroup&gt; roomGroups = new HashMap&lt;String, RoomsGroup&gt;(); </code></pre> <p>The RoomGroup is persisted correctly. And RoomGroup has also the relationship with MasterPrice </p> <pre><code>@Cascade(value = {CascadeType.DELETE_ORPHAN, CascadeType.SAVE_UPDATE}) @OneToOne(mappedBy = "roomGroup", fetch = FetchType.EAGER) private MasterPrice prices; </code></pre> <p>So far so good, MasterPrice elements are correctly stored in DB. Now inside MasterPrice there is another collection and this one seems that is never going to be persisted</p> <pre><code>@CollectionOfElements (fetch = FetchType.EAGER) @JoinTable( name = "roomgroups_masterprice_items", joinColumns = {@JoinColumn(name = "fk_masterpricesID")}) @IndexColumn(name = "position") private List&lt;MasterPriceItem&gt; dbprices = new ArrayList&lt;MasterPriceItem&gt;(); </code></pre> <p>The class MasterPriceItem is defined like this</p> <pre><code>@Embeddable public class MasterPriceItem implements Serializable{ </code></pre> <p>I defined also the equal/hashCode methods in the MasterPriceItem but it seems that hibernate is never persisting this one. I do not get any exception and when I try to load it always comes up as NULL.</p> <p>I am using hibernate_3.3.1.ga any idea that I can try? The class MasterPriceItem is correctly analysed by hibernate [if I put a field that is not in the table, I get an error]</p> <p>Any help highly appreciated. thx. </p>
    singulars
    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.
    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