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.

1105 questions
91
votes
10 answers

Steps needed to use MySQL database with Play framework 2.0

I'm new to Play framework. I'm trying to configure MySQL database as a datasource to be used with Play Ebeans. Could you some one please explain the steps that are needed to configure MySQL with Play 2.0 framework (like, downloading drivers, adding…
Veera
  • 29,772
  • 35
  • 94
  • 133
32
votes
2 answers

Ebean - Dynamic Query - Prepared Statement's Mismatched Parameter Count Error

I'm hoping someone with more Ebean expertise than myself can help me with an erratic issue I'm troubleshooting now. The environment: Java 1.7.0_17 MySQL 5.5 Play Framework 2.1.1 (however I've upgraded to Play 2.2.1 and this problem still…
jcreason
  • 777
  • 4
  • 15
26
votes
5 answers

How mature is Ebean or Siena?

In the last time I heard a lot of complaining about Hibernate. And indeed I have some painful experiences with Hibernate too. So I read about Ebean and Siena. Both have interesting approaches. Unfortunately, database access layers are very easy to…
niels
  • 7,144
  • 2
  • 33
  • 56
24
votes
3 answers

Play Framework 2.0 and Ebean SQL logging

I want to examine what SQL statements are generated by Ebean to find out why certain exceptions (related to SQL syntax) are occurring in my Play 2.0 application. Is there a way to log the SQL statements generated by Ebean in Play Framework 2.0? In…
Tommi
  • 8,450
  • 5
  • 29
  • 51
19
votes
1 answer

Getting Java Play framework to cache Ebean entities using memcached

I am running Java Play framework version v2.6.1 and using Ebean for persistence. My intention is to get bean caching going using play2-memcached plugin. What have I done so far? installed memcached on localhost and enabled verbose logging. replaced…
mindas
  • 25,644
  • 13
  • 93
  • 149
18
votes
1 answer

Ebean looks for wrong sequence name in Play Framework 2

I have an id: @Column(name = "device") @GeneratedValue(strategy = GenerationType.AUTO, generator = "device_gen") @SequenceGenerator(name = "device_gen", sequenceName = "device_id") @Id public Integer id; SequenceGenerator defines the sequenceName…
Rob Fox
  • 4,725
  • 5
  • 32
  • 59
16
votes
4 answers

Play 2.4 - Display Ebeans SQL statement in logs

How to display SQL Statements in the log ? I'm using EBeans and it fails to insert for some reasons but I can't see what's the problem. I tried to edit my config to: db.default.logStatements=true and add this to logback.xml
Gonzague
  • 322
  • 3
  • 16
16
votes
3 answers

Multiple Databases with Play Framework 2.1.x

I have 2 databases that I need to connect to. I can easily connect to them in the application.conf file like…
Bert B.
  • 579
  • 2
  • 11
  • 26
15
votes
4 answers

Difference between JPA and EBean Play Framework

I'm relatively new to Play framework, I tried following the cookbook but it seems to be already outdated. Anyways I just want to know if there's a big difference between those I have mentioned. Some tutorials used eBean whilst the others used jpa.…
xxxo_tryme
  • 213
  • 1
  • 2
  • 12
14
votes
2 answers

Duplicate columns when using EmbeddedId with a ManyToOne mapping with Ebean

I have a model called "EventCheckin" which has a ManyToOne mapping to an "Event" and a "User". The PrimaryKey of the "EventCheckin" table is the id of the user and the id of the event. I'm trying to represent this using an "EmbeddedId" in my…
InPursuit
  • 3,105
  • 20
  • 20
13
votes
1 answer

Getting NullPointerException when trying to stream().filter().collect(Collectors.toList())) on Java list

I got a problem while trying to search a specific Java object in a list. Actually i got the search function i want working for another Java class. Now i tried it for a different one but instead of returning a list of results i get a…
Elias Johannes
  • 606
  • 2
  • 7
  • 24
13
votes
4 answers

@Embedded object not instantiated automatically if it has no basic datatype fields

Fundamental question: Why aren't @Embedded objects always instantiated? The interesting observation is that Ebean does not instantiate @Embedded objects if those do not contain basic datatypes (int, boolean...) or weren't touched before.…
allprog
  • 15,913
  • 8
  • 54
  • 94
13
votes
3 answers

findRowCount doesn't work when bean has property with @Formula annotation

I have following class: @Entity @Table(name = "clients") public class Client extends Model { @Id public int id; @Formula(select = "inv.some_data", join = "left join (select 1 as some_data) as inv") public int…
Poma
  • 8,118
  • 16
  • 59
  • 137
13
votes
2 answers

How can I define 'TEXT' type using eBean in Play! framework?

When I define a variable in Model class as a String, it is converted as 'VARCHAR(255)' in DB. However, I want to save more than 255 because this data is very long text consisting of several paragraphs. As far as I remember, there is a TEXT type in…
byron1st
  • 793
  • 1
  • 8
  • 29
13
votes
5 answers

Unable to use multiple ebean databases in Play 2

We are setting up a slightly complicated project using Play Framework 2.0.3. We need to access several databases (pre-existing) and would like to do it using the frameworks built-in facilities (ie. EBean). We tried to create all model classes within…
Ricardo Zuasti
  • 151
  • 1
  • 5
1
2 3
73 74