Collection Mapping and Component Mapping Hibernate by R4R Team

Collection Mapping shows that when an object or class have the collection of values for a perticular variable, then we map those values using any one of the collection interfaces available in java.Hibernate can persist instances of java.util.Map, java.util.Set, java.util.SortedMap, java.util.SortedSet, java.util.List, and any array of persistent entities or values.

Collection Type

Mapping with Description

Java.util.List

We use this with element for mapping and initialzed with java.util.ArrayList

Java.util.Collection

It mapped with or element and initialized with java.util.ArrayList

Java.util.Map

used to map element and it initilized with java.util.HashMap

Java.util.StoreMap

used to map element and initilized with java.util.TreeMap

Java.util.sortedSet

used to map element and initilized with java.util.TreeSet.

Java.util.Set

used to map element and initilized with java.util.HashSet


Hibernate support to array with java primitive value types and every things. When we want to map a user defined collection interface that is not directly supported by Hibernate.

Component Mapping: In hibernate entity class can have a reference to another class  as a member variable. When we use referred class that class does not have it's own life cycle and completely depends on the life cycle of the owning entity class, then referred class hence therefore is called as the component class.

Collection of mapping component is also possible in a similar way just as the mapping of regular collection with maijnor configuration differences.

Component Mappings -> Mapping for a class having a reference to another class as a member variable.
Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!