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

How do I tell Play Framework 2 and Ebean to save null fields?

I'm using Play Framework 2 and Ebean. When a user submits a form to edit an existing object in the database, it doesn't save null values. I guess this is to prevent overwriting fields that aren't in the form with null. But how can I let them set…
TomahawkPhant
  • 1,130
  • 4
  • 15
  • 33
11
votes
3 answers

Today's options for an easier migration path to Play 2

I'm new to Scala and to Play, and I'm considering using them for a new project. I see the development on Play 2 is coming along nicely, although the stable version is still 1.x. And there are substantial differences between the two. What I'm…
Filipe Correia
  • 5,415
  • 6
  • 32
  • 47
11
votes
3 answers

Model.Finder Deperecated Play! 2.4

I am building an application using the latest version of Play!. When defining a Finder( as in Model.Finder) my IDE gives me a warning Finder is deprecated. I can't find any information in the documentation about Model.Finder being deprecated of any…
Travis Smith
  • 542
  • 1
  • 6
  • 21
11
votes
4 answers

OptimisticLockException with Ebean/Play

I have a Play 2.1.3 Java app using Ebean. I am getting the OptimisticLockException below. [OptimisticLockException: Data has changed. updated [0] rows sql[update person set name=? where id=? and email=? and name=? and password is null and created=?…
latj
  • 616
  • 1
  • 6
  • 23
11
votes
5 answers

Ebean using OR in query

I'm trying to make a query where I want to check if either the email or name of a user starts with a given string. In a sql query I would write this using name like 'queryString%' or email like 'queryString%' In ebean query I would expect to write…
Runar Halse
  • 3,528
  • 10
  • 39
  • 59
10
votes
1 answer

How do I describe a bridge table to Ebean?

Lets say I have these tables: ORDER: id ITEM: id ORDER_ITEM: order_id, item_id The table: ORDER_ITEM is a bridge table between ORDER and ITEM. How do I describe this threesome to Ebean? I would prefer not to use raw SQL so that I can still create…
latj
  • 616
  • 1
  • 6
  • 23
10
votes
2 answers

Play Framework 2 Ebean and InheritanceType as JOINED

After some research on Google, I haven't found anyone who has my problem that's why I'm posting it here. In my application I have three entities : User (abstract), Customer, Agency. Customer and Agency extends User. Here is the code of User…
c4k
  • 4,270
  • 4
  • 40
  • 65
10
votes
2 answers

Mapping Collection of String and Enum with Ebean (Play 2.0)

I have problems mapping a Collection of Strings and Enums in my entities. I have followed different advices, but nothing seem to work. I am using PlayFramework 2.0 and the provided Ebean as ORM. Here is an illustration class: package models; import…
kvitso
  • 298
  • 3
  • 14
9
votes
4 answers

Update method of ebean does not work in playframework

Recently I began using Play framework 2.3.8. However update of model is I am in trouble without work well. By the way, save method works. Update does not work with code like the following. (It will not be persisted to the database.) User user =…
Fuyuhiko Satou
  • 231
  • 3
  • 10
9
votes
1 answer

Ebean ManyToMany query

I have two classes, user and car. Both have ManyToMany mapping to each other. User: @Entity public class User extends Model { private int year; @ManyToMany(cascade=CascadeType.ALL) private List cars; } Car: @Entity public class…
Petteri H
  • 11,779
  • 12
  • 64
  • 94
9
votes
2 answers

How to create custom INSERT INTO query in Ebean?

I need to fill a table with large amount of data so I don't want to find related objects, but just put numeric values of them. For this I'd build a simple query ie: INSERT INTO article_category (article_id, category_id) VALUES (2,12); anyway can't…
biesior
  • 55,576
  • 10
  • 125
  • 182
8
votes
2 answers

How can I sort related entities in Ebean?

I am using Play Framework and Ebean ORM. Say, I have 2 related entity classes (Card.java and FinalMark.java) Card.java @Entity public class Card extends Model { private static final long serialVersionUID = 1L; @Id . . . @OneToMany(mappedBy…
gooamoko
  • 658
  • 12
  • 32
8
votes
4 answers

Ebean query using setDistinct() does not work

I'm using an ebean query in the play! framework to find a list of records based on a distinct column. It seems like a pretty simple query but the problem is the ebean method setDistinct(true) isn't actually setting the query to distinct. My query…
jacobduron
  • 431
  • 9
  • 20
8
votes
1 answer

Ebean - Composite primary key which contains foreign keys

I'm working with the last release of playframework (2.0.4) and the Ebean ORM. Here is my simplified db schema TABLENAME (FIELD_NAME (, ...) ) User (id) Group (id) UserGroup (user_id, group_id, is_active) I would like to create my entity models,…
Rigobert Song
  • 113
  • 2
  • 5
7
votes
4 answers

Is it possible to use @PrePersist and @PreUpdate with eBean and Play! 2.0?

I want to know if is it possible to use @PrePersist and @PreUpdate with Ebean and Play! 2.0. If so how is this feature activated. I've seen that there was a pull request adding this feature a month ago, but I can't make this work on Play 2.0. Thanks
GuidoMB
  • 2,191
  • 3
  • 25
  • 40
1
2
3
73 74