Quantcast

Merging result-map in iBatis.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Merging result-map in iBatis.

Rhishi Nema
Hi,

Could anyone suggest how we can integrate two result-map into one
using iBatis.

I have two List<Object> coming from two different result-map, both
list have a common id based on which merging has to be done i.e object
from one list has to be set into another object.

Please provide suggestion on this.

Thanks,
Rhishi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Merging result-map in iBatis.

Dridi Boukelmoune
Hi,

Have a look at discriminators, it might do the job.

Dridi

http://www.zenika.com

Le mercredi 18 avril 2012 17:09:13 UTC+2, Rhishi Nema a écrit :
Hi,

Could anyone suggest how we can integrate two result-map into one
using iBatis.

I have two List<Object> coming from two different result-map, both
list have a common id based on which merging has to be done i.e object
from one list has to be set into another object.

Please provide suggestion on this.

Thanks,
Rhishi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Merging result-map in iBatis.

Rhishi Nema


Sent from my iPhone

On 19-Apr-2012, at 11:50, Dridi Boukelmoune <[hidden email]> wrote:

Hi,

Have a look at discriminators, it might do the job.

Dridi

http://www.zenika.com

Le mercredi 18 avril 2012 17:09:13 UTC+2, Rhishi Nema a écrit :
Hi,

Could anyone suggest how we can integrate two result-map into one
using iBatis.

I have two List<Object> coming from two different result-map, both
list have a common id based on which merging has to be done i.e object
from one list has to be set into another object.

Please provide suggestion on this.

Thanks,
Rhishi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Merging result-map in iBatis.

Rhishi Nema
In reply to this post by Dridi Boukelmoune
I want to execute a select statement from within the mapper and than use the corresponding result map to merge with other. 

I was using association to achieve this and calling select from there but this causes N+1 select problems. In order to avoid this I am using resulmap parameter directly but this is not calling the select statement.

Please suggest.

Sent from my iPhone

On 19-Apr-2012, at 11:50, Dridi Boukelmoune <[hidden email]> wrote:

Hi,

Have a look at discriminators, it might do the job.

Dridi

http://www.zenika.com

Le mercredi 18 avril 2012 17:09:13 UTC+2, Rhishi Nema a écrit :
Hi,

Could anyone suggest how we can integrate two result-map into one
using iBatis.

I have two List<Object> coming from two different result-map, both
list have a common id based on which merging has to be done i.e object
from one list has to be set into another object.

Please provide suggestion on this.

Thanks,
Rhishi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Merging result-map in iBatis.

Dridi Boukelmoune
Hi,

I'm sorry I misread your fist post.
I don't know if it's actually possible to do what you want, but here is one thing you can do :

class Main {
private long id;
private String field;
private String otherFieldToBeMerged;

// getters/setters

setMyAssociation(MyAssotiation a) {
  // maybe check id
  this.otherFieldToBeMerged = a.getFieldToMerge();
}
}

class MyAssocation {
private long id;
private String fieldToMerge;

// getters/setters
}

You can make the MyAssociation class and the setMyAssociation method package private so that it's only visible within the Mapper scope.

I might have missed it but I don't know anything in MyBatis that can merge the results of two selects.

Dridi
http://www.zenika.com/

Le vendredi 20 avril 2012 07:19:31 UTC+2, Rhishi Nema a écrit :
I want to execute a select statement from within the mapper and than use the corresponding result map to merge with other. 

I was using association to achieve this and calling select from there but this causes N+1 select problems. In order to avoid this I am using resulmap parameter directly but this is not calling the select statement.

Please suggest.

Sent from my iPhone

On 19-Apr-2012, at 11:50, Dridi Boukelmoune <[hidden email]> wrote:

Hi,

Have a look at discriminators, it might do the job.

Dridi

http://www.zenika.com

Le mercredi 18 avril 2012 17:09:13 UTC+2, Rhishi Nema a écrit :
Hi,

Could anyone suggest how we can integrate two result-map into one
using iBatis.

I have two List<Object> coming from two different result-map, both
list have a common id based on which merging has to be done i.e object
from one list has to be set into another object.

Please provide suggestion on this.

Thanks,
Rhishi
Loading...