mybatis integration JAVA play

706 views
Skip to first unread message

peter ferko

unread,
Feb 6, 2013, 8:08:51 AM2/6/13
to play-fr...@googlegroups.com
Hallo,
Play is nice framework, but always missing one very important part: real persistance solution in java play. For scala anorm looks nice, but we want java solution. A lot of people don't like scala(in my opinion mainly for big complexity). I think it's not problem using scala DSL for views, or build system, but for persistence needed some mature java solution(mainly for bigger non trivial applications).
In currently looks the best mybatis.

So we want ask when:
1. Do you plan in (very)near future integration with mybatis ?
2. When 1. is yes, when do you estimate it should be ?

It's very important for us because in currently we selecting technology for bigger project(information system with  complex business logic and a lot of complex queries..). In currently winning grails, or spring mvc,  but in case mybatis integration with play we choose play.

Thx for your feedbacks :)

Martin Grotzke

unread,
Feb 6, 2013, 2:54:09 PM2/6/13
to play-fr...@googlegroups.com
Hi Peter,

in a current project we're using play 2 together with mybatis, you can
just use/integrate it. Actually we're using it in combination with
guice, doing the injector setup in Global.java. So we can inject our
mappers into services and those into managed controllers. Everything
works fine.

What are you missing exactly?

Cheers,
Martin
> --
> You received this message because you are subscribed to the Google
> Groups "play-framework" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to play-framewor...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
inoio gmbh - http://inoio.de
Schulterblatt 36, 20357 Hamburg
Amtsgericht Hamburg, HRB 123031
Geschäftsführer: Dennis Brakhane, Martin Grotzke, Ole Langbehn

James Roper

unread,
Feb 6, 2013, 4:16:05 PM2/6/13
to play-framework
On Thu, Feb 7, 2013 at 12:08 AM, peter ferko <xxxx...@gmail.com> wrote:
Hallo,
Play is nice framework, but always missing one very important part: real persistance solution in java play.

Not sure what you mean here, Play comes with support for ebean out of the box, and provides support for whatever JPA provider you want to use out of the box.  So it gives you two real persistance solutions for Java projects out of the box.
 
For scala anorm looks nice, but we want java solution. A lot of people don't like scala(in my opinion mainly for big complexity). I think it's not problem using scala DSL for views, or build system, but for persistence needed some mature java solution(mainly for bigger non trivial applications).
In currently looks the best mybatis.

So we want ask when:
1. Do you plan in (very)near future integration with mybatis ?
2. When 1. is yes, when do you estimate it should be ?

It's very important for us because in currently we selecting technology for bigger project(information system with  complex business logic and a lot of complex queries..). In currently winning grails, or spring mvc,  but in case mybatis integration with play we choose play.

Thx for your feedbacks :)

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
James Roper
Software Engineer

Typesafe - The software stack for applications that scale
Twitter: @jroper

peter ferko

unread,
Feb 7, 2013, 2:11:09 PM2/7/13
to play-fr...@googlegroups.com, martin....@googlemail.com

Are you using some play mybatis module ? I find http://www.playframework.com/modules/mybatisplay-0.1.2/home  but I don't know when is it going with play2. Is it possible to find some howto setup mybatis for play2  ?



Dňa streda, 6. februára 2013 20:54:09 UTC+1 Martin Grotzke napísal(-a):

peter ferko

unread,
Feb 7, 2013, 2:15:41 PM2/7/13
to play-fr...@googlegroups.com

In short: I don't think that ORM is a good way for writing bigger app with complex queries. I think that datamapper is better solution for that.



Dňa streda, 6. februára 2013 22:16:05 UTC+1 James Roper napísal(-a):

Martin Grotzke

unread,
Feb 7, 2013, 6:22:07 PM2/7/13
to play-fr...@googlegroups.com
On 02/07/2013 08:11 PM, peter ferko wrote:
>
> Are you using some play mybatis module ? I find
> http://www.playframework.com/modules/mybatisplay-0.1.2/home but I don't
> know when is it going with play2. Is it possible to find some howto
> setup mybatis for play2 ?

I just put this together:
http://inoio.de/blog/2013/02/07/integrating-mybatis-guice-play2/

Cheers,
Martin
> > an email to play-framewor...@googlegroups.com <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
signature.asc

peter ferko

unread,
Feb 8, 2013, 12:47:49 PM2/8/13
to play-fr...@googlegroups.com, martin....@googlemail.com
Yeah, realy nice, thanks a lot martin. I'm sure that community really appretiate this post :)


Dňa piatok, 8. februára 2013 0:22:07 UTC+1 Martin Grotzke napísal(-a):

Martin Grotzke

unread,
Feb 8, 2013, 12:56:30 PM2/8/13
to peter ferko, play-fr...@googlegroups.com

adel alfar

unread,
Feb 11, 2013, 10:23:30 AM2/11/13
to play-fr...@googlegroups.com, martin....@googlemail.com
Hello Martin,

Thank you for your info on MyBatis+Play2!  I would appreciate it if you can tell me why my playMyBatisSample Play2.1 does not recognize the Dependencies you provided.  I followed your example step on the inoio site...and play give error when compiling the Global class ...Thanks!

Martin Grotzke

unread,
Feb 11, 2013, 10:32:42 AM2/11/13
to adel alfar, play-fr...@googlegroups.com

Please post the stack trace / error details.

Cheers,
Martin

adel alfar

unread,
Feb 11, 2013, 11:11:56 AM2/11/13
to play-fr...@googlegroups.com, adel alfar, martin....@googlemail.com
edmxp:playMyBatisSample adel$ play compile
[info] Loading project definition from /Users/adel/git/playMyBatisSample/project
[info] Set current project to playMyBatisSample (in build file:/Users/adel/git/playMyBatisSample/)
[info] Compiling 1 Java source to /Users/adel/git/playMyBatisSample/target/scala-2.10/classes...
[error] /Users/adel/git/playMyBatisSample/app/Global.java:24: cannot find symbol
[error] symbol  : class Injector
[error] location: class Global
[error]   private Injector injector;
[error]           ^
[error] /Users/adel/git/playMyBatisSample/app/Global.java:27: cannot find symbol
[error] symbol  : class Application
[error] location: class Global
[error]   public void onStart(Application app) {
[error]                       ^
[error] /Users/adel/git/playMyBatisSample/app/Global.java:28: cannot find symbol
[error] symbol  : class MyBatisModule
[error] location: class Global
[error]     injector = Guice.createInjector(new MyBatisModule() {
[error]                                         ^
[error] 3 errors
[error] (compile:compile) javac returned nonzero exit code
[error] Total time: 1 s, completed Feb 11, 2013 8:57:20 AM

Martin Grotzke

unread,
Feb 11, 2013, 9:26:41 PM2/11/13
to play-fr...@googlegroups.com
Can you share your code (e.g. on github)?

Cheers,
Martin
signature.asc

adel alfar

unread,
Feb 12, 2013, 10:22:43 AM2/12/13
to play-fr...@googlegroups.com, martin....@googlemail.com

adel alfar

unread,
Feb 12, 2013, 4:03:49 PM2/12/13
to play-fr...@googlegroups.com, martin....@googlemail.com
Never mind Martin...I got it to work...I had to play clean-all, play "eclipse with-source=true", refresh my eclipse project.....after going through your article it all went well... Thank you VERY much for you help....I really would love to see more MyBatis support in Play 2.X ...Maybe in the form of Plugins. or complete examples

I would also appreciate it more if you have extra info/links for examples, info, tutorials...Thanks again!

Martin Grotzke

unread,
Feb 12, 2013, 4:41:20 PM2/12/13
to play-fr...@googlegroups.com
Great that it's working for you! I also pushed the code for the blog
post to github (referenced from the post now):
https://github.com/inoio/play-mybatis-sample

Regarding extra info/links for examples, info, tutorials: Are you
looking for s.th. in particular? What are your questions?

Cheers,
Martin
signature.asc

adel alfar

unread,
Feb 12, 2013, 5:43:00 PM2/12/13
to play-fr...@googlegroups.com, martin....@googlemail.com
I really dont have a particular question.  I was thinking of some more information/examples  about Play/MyBatis integration which might include MyBatis maps config/setup, ibator setup, service layer best practices for Play's web apps, Caching, how the MyBatis session plays with Play! 2.1 stateless nature, JSON, DAOs...

Martin Grotzke

unread,
Feb 13, 2013, 4:10:03 AM2/13/13
to play-fr...@googlegroups.com
On 02/12/2013 11:43 PM, adel alfar wrote:
> I really dont have a particular question. I was thinking of some more
> information/examples about Play/MyBatis integration which might include
> MyBatis maps config/setup, ibator setup, service layer best practices
> for Play's web apps, Caching, how the MyBatis session plays with Play!
> 2.1 stateless nature, JSON, DAOs...

I don't have further links to s.th. specific to mybatis + play, but I
also don't miss anything.

Regarding MyBatis config / setup the MyBatis / MyBatis Guice docs are
really helpful (http://www.mybatis.org/guice/).
Service layer best practices etc. are not different to general
architectural rules (the same as in any other java app), so you can do
what you want (layers, DDD etc.).

MyBatis caching of course has to be used with care, this depends on the
specific deployment scenario.
When mentioning the mybatis session in combination with plays stateless
nature, do you have anything special in mind?

If you have an idea which specific topic should be further highlighted
I'd be happy to help.

Cheers,
Martin


>
> On Tuesday, February 12, 2013 3:41:20 PM UTC-6, Martin Grotzke wrote:
>
> Great that it's working for you! I also pushed the code for the blog
> post to github (referenced from the post now):
> https://github.com/inoio/play-mybatis-sample
> <https://github.com/inoio/play-mybatis-sample>
>
> Regarding extra info/links for examples, info, tutorials: Are you
> looking for s.th <http://s.th>. in particular? What are your questions?
signature.asc

adel alfar

unread,
Feb 13, 2013, 10:22:30 AM2/13/13
to play-fr...@googlegroups.com, martin....@googlemail.com
Thanks again Martin!  

The site link was helpful.  My ultimate goal is to replace Ebean with (an eventual drop in) MyBatis plugin.  Yes, use cases my vary as far as best practices are concerned, but its good to know that you went through that already and did not see any resistance from the Play framework's play with MyBatis artifacts.  I would like to participate in an MyBatis module/plugin effort whenever that begins...and if that does not begin, then I will eventually start it.

Martin Grotzke

unread,
Feb 14, 2013, 4:05:36 AM2/14/13
to play-fr...@googlegroups.com
On 02/13/2013 04:22 PM, adel alfar wrote:
> Thanks again Martin!
>
> The site link was helpful. My ultimate goal is to replace Ebean with
> (an eventual drop in) MyBatis plugin.
You probably can't use annotated ebean models, so it can't really be a
drop-in. Or am I missing s.th.?

Yes, use cases my vary as far as
> best practices are concerned, but its good to know that you went through
> that already and did not see any resistance from the Play framework's
> play with MyBatis artifacts.
What just comes to my mind is build setup: you probably want to include
mapper xml files (located besides Mappers in the source folder) in the
classpath. To achieve this you have to adjust your Build.scala, for this
add this to play.Project(...).settings(
// Add app folder as resource directory so that mybatis mapper xml
files are visible
unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "app" ),
// but filter out java and html files that would then also be copied
to the classpath
excludeFilter in Compile in unmanagedResources := "*.java" || "*.html",
...)

I would like to participate in an MyBatis
> module/plugin effort whenever that begins...and if that does not begin,
> then I will eventually start it.
If there's s.th. that could really be useful I'd also contribute.
As it depends on the kind of integration / DI, probably for each DI
library a module/plugin would have to be provided. I need to think it a
bit so get a better idea how the plugin could look like / could be used.

Cheers,
Martin

>
>
> On Wednesday, February 13, 2013 3:10:03 AM UTC-6, Martin Grotzke wrote:
>
> On 02/12/2013 11:43 PM, adel alfar wrote:
> > I really dont have a particular question. I was thinking of some
> more
> > information/examples about Play/MyBatis integration which might
> include
> > MyBatis maps config/setup, ibator setup, service layer best practices
> > for Play's web apps, Caching, how the MyBatis session plays with
> Play!
> > 2.1 stateless nature, JSON, DAOs...
>
> I don't have further links to s.th <http://s.th>. specific to
> mybatis + play, but I
> also don't miss anything.
>
> Regarding MyBatis config / setup the MyBatis / MyBatis Guice docs are
> really helpful (http://www.mybatis.org/guice/).
> Service layer best practices etc. are not different to general
> architectural rules (the same as in any other java app), so you can do
> what you want (layers, DDD etc.).
>
> MyBatis caching of course has to be used with care, this depends on the
> specific deployment scenario.
> When mentioning the mybatis session in combination with plays stateless
> nature, do you have anything special in mind?
>
> If you have an idea which specific topic should be further highlighted
> I'd be happy to help.
>
> Cheers,
> Martin
>
>
> >
> > On Tuesday, February 12, 2013 3:41:20 PM UTC-6, Martin Grotzke wrote:
> >
> > Great that it's working for you! I also pushed the code for
> the blog
> > post to github (referenced from the post now):
> > https://github.com/inoio/play-mybatis-sample
> <https://github.com/inoio/play-mybatis-sample>
> > <https://github.com/inoio/play-mybatis-sample
> <https://github.com/inoio/play-mybatis-sample>>
> >
> > Regarding extra info/links for examples, info, tutorials: Are you
> > looking for s.th <http://s.th> <http://s.th>. in particular?
signature.asc
Reply all
Reply to author
Forward
0 new messages