dplass wrote:
First off, can you post your mapping and java code?
Secondly, it seems that (as an example from your examples), getPrivileges returns a Collection. Lets say for the sake of argument, it's a List. Then why not map it as a List?
Then you could just say
Code:
session.doLoad(user, id);
Or somesuch equivalent in your (static) Hibernate class.
Well, I figure the structure of the objects is pretty self explanatory. I use lazy-load for all many-to-many relationships. Here, a role contains privileges and a privilege contains pages.
Secondly, that is Hibernate's static class, not mine. It's a method that is meant to eagerly fetch collections marked as lazy in the xml mapping files.
Also, there is nothing here that says it's a list. In fact, it makes sense that privileges would be modeled as a set since privileges usually don't apply in any order (or at least in my application anyway). Besides, loading strategies are pretty independant of all of these details anyway - a collection is a collection.
Of well, I guess I'll keep doing it this way unless I find a better way.