Questions tagged [ebean]

Ebean is an open source Object Relational Mapping tool. It's goal is to provide a simpler alternative to JPA (Java Persistence API) implementations such as Hibernate and Eclipselink.

Ebean is an open source Object Relational Mapping tool.

It's goal is to provide a simpler alternative to JPA (Java Persistence API) implementations such as Hibernate and Eclipselink.

It does this by providing a “sessionless” API and a simpler query language. That means:

  • No Session Object (or UnitOfWork or EntityManager)
  • No Attached or Detached Beans
  • No merge(), persist(), flush(), or clear(). Instead Ebean has save() and delete()

Ebean, just like JPA has a Persistence Context but has some architectural differences to allow it to have a different approach to the entity bean lifecycle and removing the need to manage EntityManagers.

Why Ebean? ... why different from JPA?

Ebean uses the JPA Mapping annotations and will follow those very closely.

However, Ebean has been architected and built from a different perspective than JPA. The Architectural and Query language differences are reasonably fundamental to both Ebean and JPA so its hard to see these differences going away anytime soon.

JPA is architected to use an “EntityManager” which closely matches a Hibernate “Session” and a Toplink “UnitOfWork”. This brings with it the concepts that an entity bean can be attached or detached from the EntityManager (with associated merge, flush clear operations etc). If the EntityManager is used across multiple Transactions the EntityManager needs to be managed typically by a EJB Session Bean, Seam, Spring or similar container/framework.

Ebean is architected to not require an EntityManager (or Session or UnitOfWork object) with the goal of making it easier to use and to remove the requirement to manage EntityManager objects (Aka a different approach to Lifecycle management).

Although Ebean doesn't have a EntityManager it DOES have a “Persistence Context” (like JPA) and by default in Ebean the persistence context is transaction scoped and automatically managed.

1101 questions
4
votes
1 answer

Play 2.4 - using Ebean in eager singleton module

I have got a question. I am using Play Framework with Ebean. I am trying to port my application to Play 2.4 and I am trying to use dependency injection technique introduced in Play. In previous version I was using GlobalSettings.onStart() to…
spidla
  • 231
  • 1
  • 9
4
votes
2 answers

I should use Ebean or EbeanServer under what case?

I know I can use Ebean or EbeanServer to access a database. EbeanServer has more API methods than Ebean, Many methods on Ebean such as Ebean.find(Class) etc are actually just a convenient way to call methods on the 'default/primary' EbeanServer. My…
deezh
  • 114
  • 6
4
votes
1 answer

How to test database evolutions in Play Framework 2

I am using Play Framework 2.3 and have made a database evolution that is somewhat involved and requires updating new fields with values computed from old fields (that are removed in the evolution). It would be nice to test that the evolution works…
4
votes
1 answer

Caused by: javax.persistence.EntityNotFoundException: Bean has been deleted - lazy loading failed

EDIT: Additional information: play.api.Application$$anon$1: Execution exception[[EntityNotFoundException: Bean has been deleted - lazy loading failed]] 2015-11-23T04:48:23.432891+00:00 app[web.1]: at…
Dirk
  • 6,774
  • 14
  • 51
  • 73
4
votes
2 answers

Play 2.4 Ebean pagination issue

I want to use pagination in my application. Here is simple example: public static List getPage(int page, int size) { PagedList findPagedList = Ebean.find(MyClass.class).findPagedList(page,size); return…
Evgeny Makarov
  • 1,417
  • 1
  • 21
  • 41
4
votes
0 answers

Ebean batch not working

we have some trouble to get batch insert working with Ebean. We have a collection of objects to persist (about 100) and our database in on a remote area with a lots of latency. We need to send the insert with one request. I have tried to do that…
4
votes
1 answer

Play framework 2.3.x Server Error Cannot register class

I recently uploaded Play application on server. Problem is that I can ran application through command activator run it compiles and runs fine. When I try to do activator clean stage it also compiles but after …
4
votes
2 answers

Play & Ebean - get first record

How is it possible to get the first record of a table in my database using the play.db.ebean.Model.Finder, like a "first" method. The corresponding SQL would be: SELECT * FROM my_table LIMIT 1;
alainschaller
  • 113
  • 2
  • 10
4
votes
1 answer

If condition always routing towards hasError condition while submitting a form

I have created a simple form to add a shop, every shop has a manytoone relation with the member Shop.java model package models; @Entity public class Shop extends Model { @Id@SequenceGenerator(name = "shop_gen", sequenceName =…
akku
  • 469
  • 5
  • 17
4
votes
1 answer

Converting Play! framework evolution from MySQL to PostgreSQL

I am using plaframework 2.2.1, I had made a project MySQL but now i want to shift my project to PostgreSQL but having some errors recreating the DB evolution. My old evolution(1.sql) for mysql which worked fine is: # --- Created by Ebean DDL # To…
akku
  • 469
  • 5
  • 17
4
votes
1 answer

Force ebean to update the object

I have a Play Framework 2 application I use play 2.2.2 built with Scala 2.10.3 (running Java 1.7.0_25). I have a method that checks the object with his copy from secured table. If the object has been changed it will be replaced with the object…
PETRo
  • 173
  • 1
  • 7
4
votes
1 answer

How to avoid lazy loading in play framework

In play framework, I use following code to fetch values from a table called "Report" which has other relationship tables like "Project","Build" etc. List rpts = Report.find.where() .eq("publish","1") …
svjn
  • 904
  • 2
  • 19
  • 35
4
votes
1 answer

Playframework Ebean.Save() gives Connection Closed

I have a play framework with a simple Address model but upon calling ebean's #save() method I get the following errors. The database is configured correctly I think (I can read models without a problem). My unit tests which run on a in-memory H2…
Jojo
  • 278
  • 1
  • 10
4
votes
0 answers

Play Framework 2 Ebean Select Records where Join Not Null/Empty

I have a very simple DB consisting (for this example) of two tables: Users and UserOrders I want to select a list of users where there are UserOrder association (so user orders are not NULL). I have tried using .isNotNull(), but either I'm using it…
sean.boyer
  • 1,187
  • 16
  • 24
4
votes
1 answer

Inner joins in Ebean?

I read https://archive-avaje-org.github.io/ebean/introquery_joinquery.html looking at Example A, I noticed there's no specification of the inner join common column. I think their fetch-tablename syntax causes Ebean to look at what column the 2…
HukeLau_DABA
  • 2,384
  • 6
  • 33
  • 51