Java Persistence/Ebean/Quick Start - examples
From Wikibooks, open books for an open world
Some basic queries
// find a customer using their Id Customer customer = Ebean.find(Customer.class, 7); // find all customers List<Customer> list = Ebean.find(Customer.class).findList(); // find customers with names starting with Rob% List<Customer> customers = Ebean.find(Customer.class) .where().startsWith("name","Rob") .findList();
Save and Delete
// find a customer using their Id Customer customer = Ebean.find(Customer.class, 7); customer.setName("Cool Customer"); // save will update the customer Ebean.save(customer); Customer newCust = new Customer(); newCust.setName("Super Cust"); ... // save will insert the new customer Ebean.save(newCust);
This page may need to be