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

Why Ebean returns null for no reason?

Using Play Framework, I have a model like this : class MyModel extends Model { // Some columns @ManyToOne public OtherModel other; public OtherModel getOther() { return other; } } For a reason I can't understand, if I…
Cyril N.
  • 38,875
  • 36
  • 142
  • 243
5
votes
1 answer

single table inheritance (with Ebean + Play! framework)

I'm using the concept of single table inheritance because of OOP considerations of course. for example, PostLike and TopicLike inherit from Like class. I see two problems with this methodology: instead of two tables (PostLike and TopicLike) I get…
socksocket
  • 4,271
  • 11
  • 45
  • 70
5
votes
3 answers

Play Framework: 2.0.2 PersistenceException:Cannot register class in Ebean server

First of all, this question may seem much alike: Play Framework: PersistenceException: The type is not a registered entity? (Ebean) but it's not... I'm trying to save an entity but it doesn't even render the template, after I restart Play it just…
5
votes
1 answer

How can we improve Ebean's remote performance?

(Disclaimer: this is very open question, what's more I think that there will be not only one correct answer, anyway don't close it please, also consider adding the answers to community wiki) We are working on Play application using Ebean as main…
biesior
  • 55,576
  • 10
  • 125
  • 182
5
votes
3 answers

How do I enable Ebean Enhancement in Maven?

I've been using Avaje.org ebean ORM layer for a while, but I don't understand how to enable the byte-code enhancement functionality described in the "Ebean v2.6.0 User Guide" with Maven. I found a configuration example on the Avaje.org homepage, but…
JBCP
  • 13,109
  • 9
  • 73
  • 111
5
votes
3 answers

[PersistenceException: Error getting sequence nextval]

i am getting this error while trying to save data into model in db. @Entity public class User extends Model { @Required public String name; @Email public String email; @Required @MaxLength(value=10) public String username; …
doniyor
  • 36,596
  • 57
  • 175
  • 260
5
votes
1 answer

Ebean how to exclude String as column

So I have the below code. Where I am trying to create a table called SecurityType which has values ID and description. I would like to add two strings "Administrator" and "user" to it. Is there a way I can exclude these two from being columns in the…
user1434177
  • 1,947
  • 4
  • 26
  • 40
5
votes
2 answers

join two expressionList with "or" or "and"

I'm having some trouble to join 2 expressionList with an "or". This is an example of what I'm doing: RelationGroup prg =... ExpressionList exp = User.find.where(); List> expressions = new…
Hugo Alves
  • 1,555
  • 2
  • 18
  • 41
5
votes
3 answers

Play Framework: Error getting sequence nextval using H2 in-memory database

As the title suggests, I get an error running Play 2.0.1 Tests using a FakeApplication w/ H2 in memory. I set up a basic unit test: public class ModelTest { @Test public void checkThatIndustriesExist() { …
aix
  • 1,063
  • 2
  • 13
  • 24
5
votes
1 answer

How to use blob with ebean & play 2?

This is the entity contains blob type: @Entity @Table(name="image_info") public class ImageInfo extends Model { ....... @Constraints.Required private Blob image; ....... } $ play -DapplyEvolutions.default=true run I got errors…
angelokh
  • 9,426
  • 9
  • 69
  • 139
5
votes
2 answers

How to use different implementation for ebean SqlLimiter in playframework

I am using ebean as ORM and SQL Server in the back. I got an exception of SQL syntax error when I try to setMaxRows. The generated sql has something like select .... from ... where ... LIMIT 5 while this might work for mysql, SQLServer doesn't…
Wei Ma
  • 3,125
  • 6
  • 44
  • 72
4
votes
1 answer

Play Framework and autogenerated evolutions

I love bootstrapping projects with Play! Ebean, in memory database : evolutions generates automatically when I need a new model, this is awesome. I am learning Play Scala, and there is a lack of support between Ebean and Scala It can work, with…
Julien D
  • 1,259
  • 9
  • 22
4
votes
1 answer

ERROR: cannot execute UPDATE in a read-only transaction

I getting ERROR: cannot execute UPDATE in a read-only transaction in the following method at the line with user.update() call: User user; try { user = User.finder.where().eq("phoneNumber",…
Arkady
  • 1,178
  • 14
  • 35
4
votes
0 answers

Ebean: Cascade with OneToOne – tries inserts instead of update

I'm using Scala with Ebean, and I've run into some serious trouble. The situation is quite simple, I have a parent entity: @Entity case class Person(@(PrivateOwned@field) @(OneToOne@field)(fetch = FetchType.LAZY, cascade =…
Ashesh
  • 2,978
  • 4
  • 27
  • 47
4
votes
1 answer

Setting the value with condition inside for each applying to all items instead of just 1

I have really strange issue over here, the problem that I make iteration over list inside object inside list, and there is a condition for it, the problem is that second iteration has condition to set value but its applying to all items even if…
Al-Mothafar
  • 7,949
  • 7
  • 68
  • 102