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
7
votes
2 answers

How can I override Play's default Ebean server configuration?

I don't want to define the default database configuration in the application.conf file. Instead, I want to construct the default EbeanServer programmatically and inject it myself into the DAO. The problem I am having is, if I create a guice binding…
jesukumar
  • 1,139
  • 9
  • 19
7
votes
2 answers

Cascade save model not saving relationship

I have an Play2 application using eBean integrated with PostgreSQL database. Basically I have a model TripRequest that as a list of Passengers . The use case is "A trip has several passengers". For the TripRequest I have this model: @Entity public…
Miguel Ribeiro
  • 8,057
  • 20
  • 51
  • 74
7
votes
2 answers

Mysterious Play 2.4 Injection exception

Recently upgraded to Play 2.4 and I'm still learning all the little quirks and such. I'm trying to just get my index page working and I'm having a hard time of it, and I know it's something small I'm missing. Here is the error CreationException:…
Zarathuztra
  • 3,215
  • 1
  • 20
  • 34
7
votes
1 answer

My Model is NOT an Entity Bean registered with this server?

I'm using Playframework for the firstime in combination with Ebean. Now I want to use MySQL as database so I…
user1007522
  • 7,858
  • 17
  • 69
  • 113
7
votes
3 answers

hibernate vs ebean as scalable, performant ORM

We are going to write a service for which we are trying to evaluate technology stack. So as part of ORM we are thinking of using hibernate but from one of my colleague I came to know abt ebean. But we don't have any idea of ebean. So my question…
Trying
  • 14,004
  • 9
  • 70
  • 110
7
votes
1 answer

how delete all rows with no SQL

Is the any other way to delete all rows of a database table without writing an SQL delete statement? List items = Ebean.find(Item.class).findList(); Ebean.delete(items); Is there anything like Ebean.deleteAll(Item.class) in Ebean API?
tok
  • 909
  • 1
  • 10
  • 21
7
votes
1 answer

Play 2.2.2 @Transactional of eBean does not rollback transaction in Exception thrown

It seems that when using Play Framework 2.2.2 with eBean ORM the @play.db.ebean.Transactional does not rollback transaction when an Exception is thrown. Does someone of you know something about the issue and how it could be solved ? I saw that…
Simeon Angelov
  • 470
  • 4
  • 18
7
votes
2 answers

Play Framework 2 Ebean specify default value for field

I have a simple model in Play Framework 2, and I would like to specify a default value to be inserted on a specify INT column if none is provided when the INSERT is performed. Model: @Entity @Table(name = "DashboardOptions", schema = "dbo") public…
sean.boyer
  • 1,187
  • 16
  • 24
7
votes
2 answers

Cannot register class in Ebean server (Play Framework 2 - Java)

I am getting the following error when running my Play Framework 2.2.x (Java) project: Configuration error Cannot register class [models.SomeClass] in Ebean server The error messages displayed in the browser points me to the line…
plade
  • 541
  • 4
  • 15
7
votes
1 answer

Can't create a base model class in Play using Ebean

I am trying to create the following class in Play using Ebean: public class BaseModel extends Model { @Column(name = "created_at") public Date createdAt; @Column(name = "updated_at") public Date updatedAt; @PrePersist …
k9m
  • 295
  • 1
  • 3
  • 8
7
votes
2 answers

PlayFramework 2 + Ebean - raw Sql Update query - makes no effect on db

I have a play framework 2.0.4 application that wants to modify rows in db. I need to update 'few' messages in db to status "opened" (read messages) I did it like below String sql = " UPDATE message SET opened = true, opened_date = now() " …
7
votes
3 answers

Generate "on delete cascade" using Ebean

I am using Ebean and I need to end up getting "on delete cascade" as DDL (data definition language) - which annotation does that? I tried @OneToMany(cascade=CascadeType.REMOVE) but that gives "on delete restrict" / doesn't change the default "on…
stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
7
votes
2 answers

OptimisticLockException with Ebean and Play Framework 2

I am using Ebean with Play Framework 2 and sometimes it falls with OptimisticLockException of such kind: play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[OptimisticLockException: Data has changed. updated [0] rows sql[update…
Alex Povar
  • 4,890
  • 3
  • 29
  • 44
7
votes
1 answer

filterMany for Play 2 returns all results

I am using Play 2.0.2 with ebean. In Info class, I defined @ManyToMany(fetch=FetchType.EAGER) private Set members; private Date createdDate = new Date(); And MemberInfo has memberId field. When I do public static Finder
coolsuntraveler
  • 317
  • 5
  • 13
7
votes
1 answer

Store enum name, not value in database using EBean

I have this enum : public enum DocumentTypes { PDF("PDF Document"), JPG("Image files (JPG)"), DOC("Microsoft Word documents"); private final String displayName; DocumentTypes(final String display) { this.displayName = display; …
Cyril N.
  • 38,875
  • 36
  • 142
  • 243
1 2
3
73 74