Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between JPA and EBean Play Framework

I'm relatively new to Play framework, I tried following the cookbook but it seems to be already outdated. Anyways I just want to know if there's a big difference between those I have mentioned.

Some tutorials used eBean whilst the others used jpa. I am really confused.

like image 494
xxxo_tryme Avatar asked Dec 30 '13 09:12

xxxo_tryme


3 Answers

same question answered here: https://groups.google.com/forum/#!topic/play-framework/6OR1Osf4AAU

JPA is a standard which many libraries implement. Ebean uses parts of the JPA standard. Ebean expects you to annotate your models with JPA annotations. So the question, which is better, Ebean or JPA, is a strange one to answer since Ebean partially is a JPA implementation. I believe Play 2 might also offer a Hibernate integration, which more fully implements the JPA standard, and perhaps is what you were asking about? Hibernate is much more widely used in the Java community. I switched to Ebean when trying Play 2 and haven't looked back. I much prefer it to Hibernate because Hibernate had many tricky gotchas that I was always stumbling over and I haven't found any of these issues with ebean.

like image 121
Leo Avatar answered Sep 17 '22 19:09

Leo


Well in Play 2.3 they will be switching back to JPA!! James Ward, Developer Advocate at Typesafe, just told me to start new projects with JPA: https://twitter.com/_JamesWard/status/416977192019456000 (or specifically Hibernate)

Here is the official Roadmap for Play 2.3: https://docs.google.com/document/d/11sVi1-REAIDFVHvwBrfRt1uXkBzROHQYgmcZNGJtDnA/pub

For some of the reasons behind the decision to switch back to JPA: "[2.3 Roadmap] - Question for DevTeam: Why is Ebean considered to be replaced with JPA in 2.3 ?" https://groups.google.com/forum/#!searchin/play-framework/2.3/play-framework/7pL-Gq_pj7M/UykJdAC6wyYJ

And finally, James Ward created a rudimentary Play JPA Example for me on github: https://github.com/jamesward/play-java-jpa

It still needs to be enhanced with examples for searching and paging, but it is a start. I would appreciate hearing if anyone else finds a good best practice Play 2.3 JPA / Hibernate example.

like image 42
Brian Porter Avatar answered Sep 17 '22 19:09

Brian Porter


If you are interested in the more technical details around the difference between Ebean ORM and JPA (and Hibernate) and hence the reasons why Ebean exists in the first place you can have a look at:

http://ebean-orm.github.io/architecture/compare-jpa

In short there are 2 main issues:

  • Ebean ORM is "sessionless" ORM (so not attach/detach semantics, no EntityManger to manage etc)

  • Ebean ORM's query language is better designed to optimise Object graph construction (Support partial objects and avoid N + 1 - you should never have an N + 1 issue with Ebean no matter how complex the object graph).

For more details on Partial objects refer to:

http://ebean-orm.github.io/docs/query/partialobjects

For more details on N + 1 refer to:

http://ebean-orm.github.io/docs/query/nplus1

like image 41
Rob Bygrave Avatar answered Sep 19 '22 19:09

Rob Bygrave