-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Performance Issue while updating Child Collection
PostPosted: Tue Aug 17, 2010 3:23 am 
Beginner
Beginner

Joined: Sat Nov 07, 2009 10:31 am
Posts: 22
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

_________________
Jana


Top
 Profile  
 
 Post subject: Re: Performance Issue while updating Child Collection
PostPosted: Tue Aug 17, 2010 3:36 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Hi Janu019,

This can be avoided. You can save the FolderSupplier object instead of Folder.

folderSupplier.setFolder(loadedFolderObject);

aftr saving obviously when u access getFolderSupplier() from folder this can be fetched. Please try and let know any issues.

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


Top
 Profile  
 
 Post subject: Re: Performance Issue while updating Child Collection
PostPosted: Tue Aug 17, 2010 7:42 am 
Beginner
Beginner

Joined: Sat Nov 07, 2009 10:31 am
Posts: 22
Hi,

Thanks alot. I tried the same way as you said , now Its working fine.
But still my doubt is that without persisting directly child like FolderSupplier
can we do some thing to update Folder object only without loading child objects..?

Suppose what If I have some 1000 new Folder Suppliers to be added to Folder
in such case 1000 times i should persist. i think it may again leads to performance degradation.

please clarify my doubt.


Thanks,
Jana

_________________
Jana


Top
 Profile  
 
 Post subject: Re: Performance Issue while updating Child Collection
PostPosted: Wed Aug 18, 2010 1:35 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Quote:
Suppose what If I have some 1000 new Folder Suppliers to be added to Folder
in such case 1000 times i should persist. i think it may again leads to performance degradation


U have stated new Folder suppliers , however you are going to store 1000 new records in the table so it cant be avoided without persisting. Please let me know still u have doubts.

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


Top
 Profile  
 
 Post subject: Re: Performance Issue while updating Child Collection
PostPosted: Wed Aug 18, 2010 3:31 am 
Beginner
Beginner

Joined: Sat Nov 07, 2009 10:31 am
Posts: 22
I mean to say that 1000 times should i execute store(folderSupplier)

Or for these 1000 folder supplier objects if i set the folder and then if update the folder will do the needful..?

_________________
Jana


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.