-->
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: Require Hibernate Performance resolution on collections
PostPosted: Thu Jun 02, 2016 5:05 pm 
Newbie

Joined: Thu Jun 02, 2016 4:51 pm
Posts: 3
We are facing performance issue when we are adding participants related appointment and saving them. The reason I found is because
when the mapped child 'Appointment' method 'getParticipant()' is called when the mapped parent 'Participant' entity having 'getAppointment()' is invoked, creating multiple joins query, which inturn fetches unwanted recordset.

Now I do not want my parent 'Participant' method 'getAppointment()' to get called, which resolves the issue, which I could test by commenting it out.

Is there a way I give any annotation which saves me commenting method, which is a bad practice I know. There are other similar examples in the code which cannot be commented, since they are used in code. Below are the Two Entity classes having the mapped methods:

Participants {
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE}, mappedBy = "participants",
targetEntity = com.skeds.core.domain.Appointment.class, fetch = FetchType.LAZY)
@Audited(withModifiedFlag=true)
public Set<Appointment> getAppointments() {
return appointments;
}
..
..
}

Appointments {
@ManyToMany(targetEntity = com.skeds.core.domain.Participant.class, cascade = { CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.REFRESH, CascadeType.REMOVE }, fetch = FetchType.LAZY)
@Filter(name = "ACTIVE", condition = "ACTIVE=1")
@JoinTable(name = "APPOINTMENTS_HAVE_PARTICIPANTS", joinColumns = @JoinColumn(name = "APPOINTMENT_ID"), inverseJoinColumns = @JoinColumn(name = "PARTICIPANT_ID"))
@Audited(withModifiedFlag=true)
public Set<Participant> getParticipants() {
return participants;
}
..
..
}

Can someone help here. Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Require Hibernate Performance resolution on collections
PostPosted: Fri Jun 03, 2016 10:01 am 
Newbie

Joined: Thu Jun 02, 2016 4:51 pm
Posts: 3
Just FYI I tried 'LazyCollectionOption.EXTRA' but it did not work for me.


Top
 Profile  
 
 Post subject: Re: Require Hibernate Performance resolution on collections
PostPosted: Sat Jun 04, 2016 1:58 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
I suggest you remove @ManyToMany associations which don't perform very well, and replace them with two bidirectional one-to-many associations.


Top
 Profile  
 
 Post subject: Re: Require Hibernate Performance resolution on collections
PostPosted: Mon Jun 06, 2016 11:56 am 
Newbie

Joined: Thu Jun 02, 2016 4:51 pm
Posts: 3
Thanks for the reply. This will help me lot if I could implement.

I do not have an association class in between for bi directional set up. Are you referring the bi directional between the same two classes. Would that not demand duplicate methods performing same thing in the same class, although mapped differently, each with parent, and child behaviours.

Can you sketch a rough code example. Would appreciate thanks,


Top
 Profile  
 
 Post subject: Re: Require Hibernate Performance resolution on collections
PostPosted: Tue Jun 07, 2016 2:19 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You can use this example from the reference documentation.


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.