Created
March 14, 2012 09:38
-
-
Save mguillermin/2035395 to your computer and use it in GitHub Desktop.
Play 2.0 Ebean Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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