Hi Jason,
Can you plese provide the full annotaitons you used for your java map? So far I have used:
@org.hibernate.annotations.CollectionOfElements
@JoinTable(
name = "zad_category_keywords",
joinColumns = @JoinColumn(name = "Catalog_Id")
)
@org.hibernate.annotations.MapKey(
columns = @Column(name="Shop_Category_Id")
)
@Column(name = "Keywords")
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private Map<ShopCategory, String> categoryToKeywordsMap;
But the cascade delete is not working. Apparently it only applies to @OneToMany or @ManyToMany. So I want to adapt your @OneToMany annotations to get this working.
Many thanks
Jeremy
jasonwastaken wrote:
Ah, I see. I've mapped Maps in Hibernate, but it was a Map<String, List<Foo>> (simple type to list of user type), so I don't if this applies to you but here goes.
I had to create a class, call it FooList, to encapsulate the List<Foo>, then - in the class with the Map member - declare it as:
@OneToMany(cascade=CascadeType.ALL)
private Map<String, FooList> foos;
I never found a way to directly do Map<String, List<Foo>>. HTH.