Skip to content

Instantly share code, notes, and snippets.

@mguillermin
Created March 14, 2012 09:38
Show Gist options
  • Save mguillermin/2035395 to your computer and use it in GitHub Desktop.
Save mguillermin/2035395 to your computer and use it in GitHub Desktop.
Play 2.0 Ebean Sample
@Entity
public class Company extends Model {
@Id
public Long id;
@Constraints.Required
public String name;
public Company(String name) {
this.name = name;
}
public static Finder<Long, Company> find = new Finder<Long, Company>(Long.class, Company.class);
public static Company findById(Long id) {
return find.byId(id);
}
public static int count() {
return find.findRowCount();
}
public static List<Company> all() {
return find.all();
}
public static void create(Company company) {
company.save();
}
public static void delete(Long id) {
find.ref(id).delete();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment