|
| 1 | +# Ebean ORM |
| 2 | + |
| 3 | +> Ebean is a Java and Kotlin ORM (Object Relational Mapping) library for SQL databases. |
| 4 | +> It provides multiple abstraction levels: ORM queries, DTO queries, SqlQuery, and raw JDBC. |
| 5 | +> It supports PostgreSQL, MySQL, MariaDB, Oracle, SQL Server, H2, SQLite, and more. |
| 6 | + |
| 7 | +Ebean uses **bytecode enhancement** at build time (via `ebean-maven-plugin` or `ebean-gradle-plugin`) |
| 8 | +to provide dirty-checking and lazy loading without requiring field access through getters/setters. |
| 9 | + |
| 10 | +Key concepts: |
| 11 | + |
| 12 | +- Entity beans annotated with `@Entity` and `@Id` (Jakarta or javax persistence annotations) |
| 13 | +- Type-safe **query beans** (`Q`-prefixed classes) generated at compile time by `querybean-generator` |
| 14 | +- Platform-specific main dependency (e.g. `io.ebean:ebean-postgres`) — one per database platform |
| 15 | +- `DataSourceBuilder` from `io.ebean:ebean-datasource` for connection pool configuration |
| 16 | +- `DatabaseBuilder` to construct and configure the `io.ebean.Database` instance |
| 17 | +- `ebean-test` for testing with automatic Docker containers for all supported platforms |
| 18 | +- DDL generation and DB migration support built in |
| 19 | + |
| 20 | +## Getting Started |
| 21 | + |
| 22 | +- [Getting started overview](https://ebean.io/docs/getting-started/): Prerequisites and example projects |
| 23 | +- [Maven setup](https://ebean.io/docs/getting-started/maven): Add Ebean dependencies and plugins to pom.xml — includes full example pom for Postgres |
| 24 | +- [Gradle setup](https://ebean.io/docs/getting-started/gradle): Add Ebean to a Gradle project |
| 25 | +- [First entity](https://ebean.io/docs/getting-started/first-entity): Create an entity bean, add ebean.mf, run first test |
| 26 | +- [ebean-test setup](https://ebean.io/docs/getting-started/ebean-test): Configure Ebean for testing with application-test.yaml |
| 27 | + |
| 28 | +## Guides |
| 29 | + |
| 30 | +Step-by-step instructions written for AI agents to add Ebean to an existing Maven project: |
| 31 | + |
| 32 | +- [Add Ebean + PostgreSQL — Step 1: Maven POM setup](https://raw.githubusercontent.com/ebean-orm/ebean/main/docs/guides/add-ebean-postgres-maven-pom.md): Prescriptive instructions for modifying pom.xml — adds ebean-postgres, postgresql JDBC driver, ebean-maven-plugin, and querybean-generator annotation processor. Handles merging into existing annotationProcessorPaths blocks. |
| 33 | +- [Add Ebean + PostgreSQL — Step 2: Database configuration](https://raw.githubusercontent.com/ebean-orm/ebean/main/docs/guides/add-ebean-postgres-database-config.md): Configure the Ebean Database bean using DataSourceBuilder and DatabaseConfig with Avaje Inject. Covers minimal (master-only) and extended (master + read-only replica) setup. Includes verification steps and troubleshooting table. |
| 34 | + |
| 35 | +## Entities and Mapping |
| 36 | + |
| 37 | +- [Introduction to entities](https://ebean.io/docs/intro/first-entity/): Defining entity beans |
| 38 | +- [JPA mapping annotations](https://ebean.io/docs/mapping/jpa/): @Entity, @Id, @OneToMany, @ManyToOne, @ManyToMany, @Version, @MappedSuperclass, @Lob |
| 39 | +- [Collections](https://ebean.io/docs/mapping/collections): @OneToMany and @ManyToMany collection mapping |
| 40 | +- [Type mapping](https://ebean.io/docs/mapping/type/): UUID, Enums, JSON, arrays, custom types |
| 41 | +- [Naming conventions](https://ebean.io/docs/mapping/naming-convention): Table and column naming |
| 42 | + |
| 43 | +## Queries |
| 44 | + |
| 45 | +- [ORM queries overview](https://ebean.io/docs/intro/queries/orm-query): fetch graphs, partial objects, N+1 avoidance |
| 46 | +- [Query beans](https://ebean.io/docs/query/query-beans): Type-safe Q-bean queries with IDE auto-complete |
| 47 | +- [findList / findOne](https://ebean.io/docs/query/findMethods): Core find methods |
| 48 | +- [where expressions](https://ebean.io/docs/query/where): Filtering with expressions |
| 49 | +- [fetch / fetchGroup](https://ebean.io/docs/query/fetch): Controlling which associations to load |
| 50 | +- [DTO queries](https://ebean.io/docs/query/dtoquery): Map query results directly to DTO classes |
| 51 | +- [SqlQuery](https://ebean.io/docs/query/sqlquery): Raw SQL with Ebean type mapping |
| 52 | +- [orderBy / select](https://ebean.io/docs/query/select): Selecting columns and ordering |
| 53 | + |
| 54 | +## Persistence |
| 55 | + |
| 56 | +- [Save, update, delete](https://ebean.io/docs/persist/): Insert, update, delete entity beans |
| 57 | + |
| 58 | +## Transactions |
| 59 | + |
| 60 | +- [Transactions overview](https://ebean.io/docs/transactions/): @Transactional annotation, transaction scopes |
| 61 | +- [Batch inserts/updates](https://ebean.io/docs/transactions/batch): JDBC batch support |
| 62 | + |
| 63 | +## DB Migrations |
| 64 | + |
| 65 | +- [DB Migrations overview](https://ebean.io/docs/db-migrations/): Generate and run database migrations |
| 66 | +- [Migration detail](https://ebean.io/docs/db-migrations/detail): Repeatable, init, and versioned migrations |
| 67 | + |
| 68 | +## Testing |
| 69 | + |
| 70 | +- [Testing overview](https://ebean.io/docs/testing/): ebean-test, Docker containers, H2, DDL modes |
| 71 | +- [CI Testing](https://ebean.io/docs/ci-testing/): Running tests in CI environments |
| 72 | + |
| 73 | +## Setup and Configuration |
| 74 | + |
| 75 | +- [DatabaseConfig / ServerConfig](https://ebean.io/docs/setup/serverconfig): All DatabaseConfig options |
| 76 | +- [Enhancement](https://ebean.io/docs/setup/enhancement): Bytecode enhancement — Maven, Gradle, IDE agents |
| 77 | +- [Logging](https://ebean.io/docs/setup/logging): SQL logging, transaction logging, DDL logging |
| 78 | + |
| 79 | +## Optional |
| 80 | + |
| 81 | +- [Read replicas](https://ebean.io/docs/read-replicas/): Configuring read-only datasource for read replicas |
| 82 | +- [Kotlin support](https://ebean.io/docs/kotlin/): Using Ebean with Kotlin |
| 83 | +- [Multi-database](https://ebean.io/docs/multi-database/): Working with multiple Database instances |
| 84 | +- [Spring integration](https://ebean.io/docs/setup/spring): Using Ebean with Spring Framework |
| 85 | +- [DDL generation](https://ebean.io/docs/ddl-generation/): How Ebean generates DDL from entity models |
| 86 | +- [Tuning / autotune](https://ebean.io/docs/tuning/): Query profiling and automatic query tuning |
| 87 | +- [GraalVM native image](https://ebean.io/docs/setup/graalvm): Building GraalVM native executables with Ebean |
| 88 | +- [Examples](https://ebean.io/docs/examples): Example projects for Maven, Gradle, Kotlin, PostGIS |
0 commit comments