Just need a quick Help from you all. I have used mappedBy
Instead of @JoinColumn
just for performance Optimization:
@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="user")
I have been advised to set fetch=FetchType.EAGER
.
But I don't want to do that. Is there any other way to get lazily Loaded Collection Objects.
Or should I use @JoinColumn
for that?
And mappedBy
is then how useful for other if not able to read it lazily.
Sample entities
@Entity
@Table(name="users,uniqueConstraints=@UniqueConstraint(columnNames= "username"))
public class Users implements java.io.Serializable {
private Set<IDPMaster> idpMaster;
public void setIdpMaster(Set<IDPMaster> idpMaster) {
this.idpMaster = idpMaster;
}
@OneToMany(cascade = CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="user")
public Set<IDPUserManagerMapping> getIdpMapping() {
return idpMapping;
}
//Getters and Setters
}
@Entity
@Table(name="IDP_Master",schema="eb")
public class IDPMaster implements Serializable {
private Users idpUsers;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="paticipant_id",nullable=false)
public Users getIdpUsers() {
return idpUsers;
}
public void setIdpUsers(Users idpUsers) {
this.idpUsers = idpUsers;
}
}