Difference between JPA and EBean Play Framework
Asked Answered
H

4

15

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.

Hegyera answered 30/12, 2013 at 9:41 Comment(0)
R
20

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.

Rightness answered 30/12, 2013 at 10:1 Comment(0)
T
19

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.

Tunnel answered 30/12, 2013 at 10:49 Comment(2)
So Play 2.3 is out, but I'm confused because it still says EBean is default. You can integrate with JPA and add something for hibernate to persistence.xml. So is Hibernate not going to be the default?Turenne
Disclosure: I develop Ebean ORM, I can tell you it is not going away. For those wanting "Sessionless ORM" and life without N + 1, and automatic query tuning and streaming queries, and ElasticSearch integration, and ... well, you know where to look.Behl
B
7

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

Behl answered 7/4, 2016 at 7:28 Comment(0)
D
3

EBean is simpler to use. Look at the sample app ComputerDatabase that comes with Play. You might want to use EBean while you are learning Play, since EBean is the current default.

However, the future is JPA, so you might want to just take the plunge and learn it. There is a sample ComputerDatabaseJPA, that also comes with Play.

Dunbarton answered 30/12, 2013 at 16:37 Comment(1)
the future is JPA ... we shall see in 10 years won't we. Architecturally JPA has some issues ... hence no "streaming queries" and no "stateless updates" and poor N + 1 issues.Behl

© 2022 - 2024 — McMap. All rights reserved.