I am facing Performance issue while storing(updating) the collection of childs.
Here is the class
Code:
public class Folder {
private Set<FolderSupplier> folderSupplier = new HashSet<FolderSupplier>(0);
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "folder")
@NotAudited
public Set<FolderSupplier> getFolderSupplier() {
return folderSupplier;
}
/** @param folderSupplier the folderSupplier to set */
public void setFolderSupplier(Set<FolderSupplier> folderSupplier) {
this.folderSupplier = folderSupplier;
}
protected void addFolderSupplier(FolderSupplier folderSupplier) {
this.folderSupplier.add(folderSupplier);
}
}
class FolderSupplier {
private Folder folder;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "FLDR_ID", nullable = false)
public Folder getFolder() {
return this.folder;
}
}
The models are mentioned above.
I want to add one new FolderSupplier to Folder
as below
Code:
Folder folder = entityManager.read(12l);
FolderSupplier folderSupplier = new FolderSupplier ();
folder.addFolderSupplier(folderSupplier );
entityManager.store(folder);
The above code at line
folder.addFolderSupplier(folderSupplier );
will load all FolderSupliers for the folder and then it will add new foldersupplier to collection.
What if I have 70000 folderSuppliers associated with this Folder.
it will load all 70k objects Lazily and then it will add new FolderSupplier.
This is causing Performance issue.
could you please someone suggest is there any way to do this without loading Child objects.
Thanks in Advance,
Jana