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

Inner join in play framework ebean

I have a query which i want to write in my Product model select * from shop inner join product on product.shops_id=shop.id where product.name=keyword Shop.java public class Shop extends Model { @Id @SequenceGenerator(name="shop_gen",…
akku
  • 469
  • 5
  • 17
5
votes
1 answer

form binding: relationship with intermediate entity (nested entity) - indirect Entity creation and binding

My simplified model looks like this: @Entity public class Aspect extends Model { @Id public Long id; @OneToMany(cascade = CascadeType.ALL) public List restrictions; } @Entity public class Restriction extends Model { @Id…
Leo
  • 2,097
  • 21
  • 35
5
votes
1 answer

Ebean and many-to-many relationships - how?

I created a schema in MySQL Workbench: How do I map this to entities in Ebean in Play Framework? In the tutorials they use approach to write a model class, annotate it with @Entity and let Play generate the SQL script but there is no concern about…
pmichna
  • 4,800
  • 13
  • 53
  • 90
5
votes
4 answers

MySQL PersistenceException, "Connection is closed" in Play! 2.2

I'm trying out Play framework and using 2.2.0 version and Java version. I want to use MySQL as the database, and I've followed the instruction at the site. I am able to get evolution script running, but I can't save anything to the database. The…
dieend
  • 2,231
  • 1
  • 24
  • 29
5
votes
1 answer

Play: Custom Ebean constraints

I just started with Play and am trying to get some custom constraints on my model. I have found that this works @Constraints.Required @Constraints.MaxLength(15) @Constraints.MinLength(4) @Constraints.Pattern(value = "^\\w\\s$") public String…
Matthijn
  • 3,126
  • 9
  • 46
  • 69
5
votes
2 answers

play.db package not found in play 2.1.3

Im trying to follow the play framework ebean tutorial here: http://www.playframework.com/documentation/2.1.2/JavaEbean However when I try to include play.db.ebean.* and try to compile, the package is not found (no play.db package). I have added…
nfvindaloo
  • 948
  • 2
  • 11
  • 24
5
votes
1 answer

PersistenceException when I was using Ebean in Play framework

I am writing a web application in Java by using Play Framework 2.1.0. And I am using Ebean to manipulate the database. But I got one problem now: I have a model class called book with an int type column called page: public int page; …
Mingrui Ji
  • 399
  • 2
  • 6
  • 11
5
votes
1 answer

Mapping RawSql Result to Object in Java Ebean

Let's say I have a class Article which is automatically mapped by Java Ebean as a database table. For this table I wanted to retrieve entries via a RawSql query, because I find SQL more simple when it gets to complex queries with many joins and…
odaa
  • 251
  • 1
  • 13
5
votes
3 answers

Howo to query tables with onetomany and manytoone relationship using Ebean

I am using Play Framework 2.1.0 and Ebean and I am having a problem while querying the following scenarios listed below : I have 3 classes which represent tables in the database. class project { ... @OneToMany public SubProject sub; …
Santhosh S
  • 1,141
  • 6
  • 21
  • 43
5
votes
1 answer

Play framework 2.1 and Ebean : @ManyToOne and @OneToMany, CRUD and cascade problems

I want to realize is that: when I delete the category ,all its related articles can be deleted and when I delete the article, it can also be deleted in it's related category. I set the mapping relationship @ManyToOne and @OneToMany(cascade =…
Hedgehog
  • 61
  • 4
5
votes
1 answer

ebean unidirectional @OneToOne relation with unique constraint

I have a User class: @Entity public class User extends Model { @Id public Long id; public String email; public String name; public String password; } and a driver class @Entity public class Driver extends Model { @Id public Long id; @OneToOne…
xdev
  • 659
  • 11
  • 23
5
votes
2 answers

How to turn off EBean enhancement

I have been using Ebean with enhancement for a while. It works most of the time but it's very brittle and really cumbersome to get the configuration right. I hope turning it off could improve the robustness. My issue is that if I turn off the…
allprog
  • 16,540
  • 9
  • 56
  • 97
5
votes
2 answers

How do I do select in list with Ebean createSqlQuery

I'm building a Play2 app with Ebean. I have created a service class with a method for getting venues by a list of ids: public static List getVenuesForIds(List list){ ArrayList venues = new ArrayList(); …
jakob
  • 5,979
  • 7
  • 64
  • 103
5
votes
2 answers

Play 2.0 Framework - find all that haven't expired

I'm trying to figure out how I can go about finding members of a list - but only ones that haven't past their expired date - which is one of the properties of the model. Right now I have: public static Result getAllNotifications() { …
pixelworlds
  • 818
  • 2
  • 11
  • 22
5
votes
1 answer

ManyToMany Association (BeanList deferred)

I have a ManyToMany-Association like this: @Entity public class User extends Model implements RoleHolder { @ManyToMany(cascade=CascadeType.ALL) public List tasks; } Then I do that: User u =…
bembii
  • 259
  • 2
  • 12