Get IDs out of Uninitialized Persistent Collection
I have a situation that I have not found an answer to when looking through the Hibernate API documentation or on SO.
We have a disconnected setup, and we send entities and collections back across the wire. We are looking at a way to use a localized cache to reduce some of the wire traffic, and I am t开发者_JAVA技巧rying to figure out if there is a way to get the IDs of entities in a persistent collection (specifically, PersistentSet) without intializing the set?
No, there can't be; a PersistentCollection does not contain the ids of the associated entities - if that were its purpose, it would be an ordinary collection holding lazy loading proxies for the associated ids.
Checking membership generally requires an additional query or join (the foreign key is not on the same table as the primary key ...), which is sufficiently expensive to merit a facility to defer loading it. That facility is the persistent collection.
精彩评论