I was wondering how @Mappers and @TypeAliases (package
com.google.code.ibaguice.core.configuration) are supposed to be used?
Eelco
dont worry, feel free to ask whatever you want :-)
So.. basically @Mapper and @TypeAliases are used by core class module
com.google.code.ibaguice.core.SqlSessionFactoryModule to bind your
ibatis mapper and typealiases, and create an iBatis configuration
through
com.google.code.ibaguice.core.configuration.ConfigurationProvider.
take a look this: com.google.code.ibaguice.samples.AbstractTestCase
and com.google.code.ibaguice.samples.SimpleTestCase
...
// bindings
SqlSessionFactoryModule ibatisModule = new
SqlSessionFactoryModule(this.getDataSourceProviderClass());
ibatisModule.addSimpleAliases(Contact.class);
ibatisModule.setMapperClasses(getMapperClass());
Injector injector = Guice.createInjector(ibatisModule,
...
with this snippet you can configure programmatically the main module
with your mapper and to register your typeAlias.
If you are familiar with ibatis xml configuration file, the snippet
above is equals to:
<configuration>
<typeAliases>
<typeAlias alias="Contact"
type="com.google.code.ibaguice.samples.Contact"/>
</typeAliases>
....
<mappers>
<mapper
resource="com.google.code.ibaguice.samples.ContactMapper.xml"/>
</mappers>
...
</configuration>
I hope I've been helpful
ciao
Ah, ok... so if I understand correctly it is a multi-map like trick
you use internally; @Mappers and @TypeAliases are not intended to be
used by regular clients.
Cheers,
Eelco
Yes, correct
ciao.
http://people.apache.org/~simonetripodi/
http://people.apache.org/~simonetripodi/
On Thu, Feb 18, 2010 at 1:40 AM, Simone Tripodi
<simone....@gmail.com> wrote:
> Hi Eelco!
> do you have any feedback/suggestion for us to improve the library? :P
> Thanks in advance!!!
Well, I've been a bit side tracked unfortunately, and I might just
write a few classes myself to fit in the frameworks I wrote for my
company, as that'd be simpler. Again, the main stumble block is that I
need to support multiple data sources, and while you could build that
in to ibaguice, it might make the library more complicated, so it
might not be the best idea. I think ibaguice is nice as it is tbh.
I did also take a look at writing something that would fit into
warp-persist, but concluded that, while I like warp-persist, ibaguice
is better for ibatis, since it supports some things in a more
straightforward fashion (like what you can configure as part of
@Transactional).
Anyway, hopefully I'll have a bit time next week to work on iBatis
integration. If I have something to share from that experience, I
won't hesitate :-)
Thanks!
Eelco