Fetch Type and CascadeType
FetchType (select) => It is a enum, having 2 possible values.
EAGER: While fetching(selecting) parent data we can get child data,Employee with Profile object ,It is default for Non -Collection Type (EAGRER LOADING/EARLY LOADING)
LAZY : While fetching(selecting) parent data we dont get child data,Employee object only ,It is default for Collection Type (LAZY LOADING/LATE LOADING)
*) When child is Many -- default is LAZY
*) When child is One -- default is EAGER
CascadeType
*) When we perfom one operation on parent object if we want to perform same operation on child also then it is called as Cascading (connected operation)
@Entity
@Table(name="prodtab")
public class Product {
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name="midFk")
private Set mobs; //HAS-A
}
*) For Collections cascading is good approch.
@OneToMany(cascade = CascadeType.PERSIST) //only for save
@OneToMany(cascade = CascadeType.REMOVE)//only for delete
*) There is no default value for cascading, if we do not write any cascacde type.
No Comments Yet!!