java - Persistent set is empty with Hibernate -


i have entity few fields of type set. when retrieve entity database set empty though associations correct in database.

@valid @notnull @onetomany(fetch = fetchtype.eager) private set<location> locations; 

i have tried enabling eager fetching force hibernate load assocations when retrives entity it's empty. other fields non-collection types populated correctly.

i have never seen before hibernate, doing wrong?

thanks

not 100% 99% sure need add cascade @onetomany - default cascade no cascade @ all, meaning if persist entity, location collection not persisted..

try this:

@valid @notnull @onetomany(fetch = fetchtype.eager, cascade = cascadetype.all) private set<location> locations; 

in other words issue not collection not being fetched, not being persisted in first place (did see in location , join table?)

edit - see wrote associations correct, persist location objects separately?


Comments