Question

What are the intended use cases for CustomCollectionType vs. UserCollectionType ?

Which one should I use if I want to use my own collection with Hibernate?

This example uses UserCollectionType. I could not find examples using CustomCollectionType though, how can CustomCollectionType be used ?

What are the advantages/disadvantages of using CustomCollectionType vs. UserCollectionType ?

Was it helpful?

Solution

UserCollectionType is for when you want to rely on Hibernate's collection handling when handling persistence, but want to expose a different class to clients of your persistent objects. For example, if you have an Auction and a one-to-many of Bids, you might want Hibernate to treat this a set when persisting, but you might want getBids() to return a FastSet (as in your link).

CustomCollectionType is for when you want to persist a collection in a completely different way with different semantics using a new implementation of PersistentCollection. I'm not sure when you'd really want to do this except to change some Hibernate framework behavior.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top