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
1 answer

Complex joins using Play Framework and Ebean

I'm using the PlayFramework and I'm really liking it. When I want to grab data from a table, for example I have a user table, I use the following syntax: List users = User.find.where().eq("email", email).findList(); My question is that when I…
KVISH
  • 12,923
  • 17
  • 86
  • 162
6
votes
1 answer

Play Framework: PersistenceException: The type is not a registered entity? (Ebean)

I'm following the Play Framework 2.0 tutorial for Java and get this error when trying to save an ebean Model (task.save()). [PersistenceException: The type [class models.Task] is not a registered entity? If you don't explicitly list the entity…
Rob Fox
  • 5,355
  • 7
  • 37
  • 63
6
votes
0 answers

How to write unit test for Ebean in play framework

I have an application based on play framework scala version 2.11.1. There are couple of methods for which I want to add unit tests. These methods have direct calls to database through Ebean. I tried with this link to use mocki-ebean in order to…
Waqar Haider
  • 119
  • 1
  • 11
6
votes
3 answers

Play Framework sbt assembly jar running error :- "No root server path supplied"

I built play framework project jar with sbt assembly command. when I run the jar with Java -jar "jarName.jar" it throws error "No root server path supplied" any suggestions ?
6
votes
2 answers

Ebean Query by OneToMany Relationship

I'm using Ebean with the Play 2 Framework and got two models: a user model and a book model. The user model is connected with the book model in a OneToMany Relationship. So every user can have many books or no book at all. The book model itself has…
fabian.kirstein
  • 708
  • 8
  • 26
6
votes
1 answer

Slow chunk response in Play 2.2

In my play-framework-based web application users can download all the rows of different database tables in csv or json format. Tables are relatively large (100k+ rows) and I am trying to stream back the result using chunking in Play 2.2. However…
p00ya00
  • 796
  • 1
  • 10
  • 20
6
votes
1 answer

Play + Ebean + JPA: Cascade a delete on a OneToOne mapping

This is related to this question, but the example below is shorter, so I figured another question on this would make sense. I have two entities, A and B, in a one-to-one relationship. For an A, a B is optional, and every B must have an A. I want to…
user1995521
  • 295
  • 3
  • 10
6
votes
1 answer

Play Framework Ebean BigDecimal fraction

I am using the Play Framework with Ebean and H2 database. The problem is, the BigDecimal results in the DB script as: sum decimal(38), but what I want is: sum decimal(38,2), I already tried to define…
6
votes
1 answer

How to eager load a collection in ebean?

What is the correct way to eager fetch a nested collection in ebean and Play Framework 2? I tried this: Registration registration = find .fetch("participants") .fetch("participants.fieldValues") .fetch("participants.fieldValues.field") …
TomahawkPhant
  • 1,130
  • 4
  • 15
  • 33
5
votes
0 answers

Play 2.6 Ebeans relationship error

Posts Model /*set many to one relation with Privacy_Level model*/ @ManyToOne//(fetch = FetchType.LAZY) @JoinColumn(name = "privacy_level_id",referencedColumnName = "id", insertable = false, updatable = false) public Privacy_Level…
CraZyDroiD
  • 6,622
  • 30
  • 95
  • 182
5
votes
1 answer

What is the simplest way to create nested objects in Ebean?

I need two Ebean model classes called "States" and "Children". A "State" object can contain nested Child objects(List of children). Here is the basic States class, @Entity public class States extends Model { @Id @GeneratedValue(strategy =…
Vidura Mudalige
  • 810
  • 2
  • 18
  • 31
5
votes
3 answers

Using PlayFramework + Ebean with Gradle

I'm trying to use the Play Gradle Plugin to compile/package a Play 2.3.x app that uses Ebean. Everything works fine during compilation and packaging, but when I run the app I get the well known error Entity type class SomeEntity is not an enhanced…
Salem
  • 12,808
  • 4
  • 34
  • 54
5
votes
1 answer

Setting a Foreign Key using ebean in Play Framework

I have two model classes CustomerAccount @Entity public class CustomerAccount extends Model { @Id @Column(columnDefinition = "int(11)") public int customer_id; @Column(columnDefinition = "varchar(50) not null unique") public…
Anand Kumar
  • 75
  • 1
  • 5
5
votes
1 answer

Ebean OrderBy CASE WHEN

When using Ebean finder, is it possible to provide a order by statement like the following: ORDER BY CASE WHEN a = 'FOO' THEN 1 WHEN a = 'BAR' THEN 2 ELSE 99 END
binarymelon
  • 904
  • 2
  • 12
  • 26
5
votes
2 answers

How to make left join on two parameters in Ebean?

I have two tables: "users" and "mail_list" with corresponding classes. These tables are connected with the help of foreign key user_id (in mail_list table) that references id (in users table). Users can have records of two kinds in mail_list table -…
velika12
  • 141
  • 1
  • 6