io.ebean.package.html Maven / Gradle / Ivy
Ebean core API
Core API (see Database, DB and Query).
Database
Provides the main API for fetching and persisting beans. We can obtain the "default database"
via DB.getDefault()
or just use methods on DB.
{@code
// Example find by id
Order order = DB.find(Order.class, 10);
// Example save
Customer customer = DB.getReference(Customer.class, 42);
Order newOrder = new Order();
newOrder.setStatus(Order.Status.NEW);
newOrder.setCustomer(customer);
...
DB.save(newOrder);
// Example: Eagerly fetching associations
// fetch Customer 42 including their billing and shipping addresses
Customer customer = DB.find(Customer.class)
.setId(42)
.fetch("billingAddress")
.fetch("shippingAddress")
.findOne();
Address billAddr = customer.getBillingAddress();
Address shipAddr = customer.getShippingAddress();
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy