What are Collection types in Hibernate?- A collection is defined as a one-to-many reference. The simplest collection type in Hibernate is <bag>.
- This collection is a list of unordered objects and can contain duplicates. This is similar to java.util.List. The content of a collection is required for a SQL query. This won’t work until the code is actually accessed.
- This process has a benefit that allows the developer to separate the database access logic from that of the object traversal logic. This is called lazy collection.
- Filtering logic can be applied with lazy collection. This can alter the SQL which invokes when the actual collection is invoked.What are Collection types in Hibernate?- ArrayType, Constructor: ArrayType(String role, String propertyRef, Class elementClass, boolean isEmbeddedInXML)
- BagType, Constructor: BagType(String role, String propertyRef, boolean isEmbeddedInXML)
- CustomCollectionType: A custom type for mapping user-written classes that implement PersistentCollection Constructor: CustomCollectionType(Class userTypeClass, String role, String foreignKeyPropertyName, boolean isEmbeddedInXML)
- IdentifierBagType, Constructor: IdentifierBagType(String role, String propertyRef, boolean isEmbeddedInXML)
- ListType, Constructor: ListType(String role, String propertyRef, boolean isEmbeddedInXML)
- MapType, Constructor: MapType(String role, String propertyRef, boolean isEmbeddedInXML)
- SetType, Constructor: SetType(String role, String propertyRef, boolean isEmbeddedInXML)
|