Dear all,
I have a Hibernate class which is essentially just a wrapper around loads of collections.
So the class is (massively simplified/pseudo) something like:
@Entity public class MyClass { @OneToMany Map1 @OneToMany Map2 @OneToMany Map3 AddToMap1(); AddToMap2(); AddToMap3(); RemoveFromMap1(); RemoveFromMap2(); RemoveFromMap3(); DoWhateverWithMap1(); DoWhateverWithMap2(); DoWhateverWithMap3(); }
etc. Each of those Maps then has a few methods associated with it (add/remove/interrogate/etc).
As you can imagine, by the time I added the 10th collection or so, the class is getting a tad ridiculous in size.
What I'd love to do is something along the lines of:
@Entity public class MyClass { ClassWrappingMap1; ClassWrappingMap2; ClassWrappingMap3; }
With all the various methods wrapped up in those classes:
public class ClassWrappingMap1 { @OneToMany Map AddToMap(); RemoveFromMap(); DoWhateverWithMap(); }
I thought perhaps I could use @Embedded
for this, but I don't seem to be able to get it to work (Hibernate simply doesn't even try to persist the Map inside the wrapperClass).
Has anyone ever done something like this before? Any hints?
Many thanks,
Ned