Quantcast

similar queries, same mapper interface...

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

similar queries, same mapper interface...

Daniel Suen
This post has NOT been accepted by the mailing list yet.
I have some similar queries against a set of databases from the same vendor with different credentials, all should be using the same mapper interface. Does MyBatis 3.0.6 support that? I ran into the situation where I need to create mappers of different names, but all derived from the same parent interface,

interface parentMapper {
....
}

interface MapperA extends parentMapper { }

interface MapperB extends parentMapper { }

...

Now, with different databases, I tried looping through, each of which would try to get the right mapper interface class,

sqlSession.getMapper(x);

where x is created by a factory method that returns the type Class. It just does not seem to work, I know this may have something to do with Java generics where type erasure may be the issue. Can someone tell me how I should make all this work? Or the right way of doing this? Thanks.

In other words, different environment, different queries, but same interface are required.
Loading...