See: Description
Package | Description |
---|---|
com.avaje.ebean |
Core API (see EbeanServer and Ebean).
|
com.avaje.ebean.annotation |
Extra deployment annotations
|
com.avaje.ebean.bean |
Enhanced beans API and Support objects
|
com.avaje.ebean.cache |
Server Cache Service
|
com.avaje.ebean.common |
Common non-public interfaces and implementation.
|
com.avaje.ebean.config |
Configuration settings for EbeanServer construction
|
com.avaje.ebean.config.dbplatform |
Database platform specific support
|
com.avaje.ebean.dbmigration |
Generation DDL migration scripts based on changes to the model.
|
com.avaje.ebean.event |
Persist and Query Event Controllers and Listeners
|
com.avaje.ebean.event.changelog |
Provides a built in change log mechanism and can audit changes.
|
com.avaje.ebean.event.readaudit |
Provides Auditing of read events including queries and L2 cache.
|
com.avaje.ebean.meta |
Meta data that can be retrieved for the EbeanServer.
|
com.avaje.ebean.plugin |
Provides a API for plugins.
|
com.avaje.ebean.search |
Provides text search expressions like Match, TextQueryString etc.
|
com.avaje.ebean.text |
Utility objects for CSV, JSON and XML processing.
|
com.avaje.ebean.text.csv |
CSV processing objects.
|
com.avaje.ebean.text.json |
JSON formatting and parsing objects (See JsonContext).
|
com.avaje.ebeanservice.docstore.api |
The service API for document store integration.
|
com.avaje.ebeanservice.docstore.api.mapping |
Mapping for document store integration.
|
com.avaje.ebeanservice.docstore.api.support |
Support objects for implementing integration.
|
com.avaje.ebeanservice.docstore.none |
"No op" implementation of document store.
|
Provides the main API for fetching and persisting beans with Ebean.
For a full description of the query language refer to Query.
// fetch order 10
Order order = Ebean.find(Order.class, 10);
// fetch Customer 7 including their billing and shipping addresses
Customer customer = Ebean.find(Customer.class)
.fetch("billingAddress");
.fetch("shippingAddress");
.setId(7)
.findUnique();
Address billAddr = customer.getBillingAddress();
Address shipAddr = customer.getShippingAddress();
// Note: This example shows a "Partial Object".
// For the product objects associated with the
// order details only the product id and name is
// fetched (the product objects are partially populated).
// fetch orders for customer.id = 2
List<Order> orderList = Ebean.find(Order.class);
.fetch("customer")
.fetch("customer.shippingAddress")
.fetch("details")
.fetch("details.product","name")
.where().eq("customer.id",2)
.findList();
// Note: Only the product id and name is fetched for the
// product details. This is referred to as a
// "Partial Object" (one that is partially populated).
// code that traverses the object graph...
Order order = orderList.get(0);
Customer customer = order.getCustomer();
Address shipAddr = customer.getShippingAddress();
List<OrderDetail> details = order.getDetails();
OrderDetail detail = details.get(0);
Product product = detail.getProduct();
String productName = product.getName();
// get a Customer reference so we don't hit the database
Customer custRef = Ebean.getReference(Customer.class, 7);
// create a new Order object
Order newOrder = new Order();
newOrder.setStatus(Order.Status.NEW);
newOrder.setCustomer(custRef);
ArrayList orderLines = new ArrayList();
newOrder.setLines(orderLines);
...
// add a line to the order
Product prodRef = Ebean.getReference(Product.class, 41);
OrderLine line = new OrderLine();
line.setProduct(prodRef);
line.setQuantity(10);
orderLines.add(line);
...
// save the order and its lines in a single transaction
// NB: assumes CascadeType.PERSIST is set on the order lines association
Ebean.save(newOrder);
// Get access to the Human Resources EbeanServer/Database
EbeanServer hrServer = Ebean.getServer("HR");
// fetch contact 3 from the HR database
Contact contact = hrServer.find(Contact.class, 3);
contact.setStatus(Contact.Status.INACTIVE);
...
// save the contact back to the HR database
hrServer.save(contact);
Copyright © 2016. All rights reserved.