本文整理汇总了Java中com.avaje.ebean.Ebean类的典型用法代码示例。如果您正苦于以下问题:Java Ebean类的具体用法?Java Ebean怎么用?Java Ebean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Ebean类属于com.avaje.ebean包,在下文中一共展示了Ebean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result create() {
// Get the form from the request
Form<Instructor> form = Form.form(Instructor.class,Instructor.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Instructor object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Instructor.create(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return created(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error creating object"), e);
return internalServerError("Error creating object");
} finally {
Ebean.endTransaction();
}
}
示例2: update
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result update(Long id) {
// Get the form from the request
Form<Person> form = Form.form(Person.class,Person.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Person object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Person.update(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return ok(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error updating object"), e);
return internalServerError("Error updating object");
} finally {
Ebean.endTransaction();
}
}
示例3: create
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result create() {
// Get the form from the request
Form<Administrator> form = Form.form(Administrator.class,Administrator.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Administrator object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Administrator.create(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return created(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error creating object"), e);
return internalServerError("Error creating object");
} finally {
Ebean.endTransaction();
}
}
示例4: update
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result update(Long id) {
// Get the form from the request
Form<Administrator> form = Form.form(Administrator.class,Administrator.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Administrator object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Administrator.update(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return ok(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error updating object"), e);
return internalServerError("Error updating object");
} finally {
Ebean.endTransaction();
}
}
示例5: update
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result update(Long id) {
// Get the form from the request
Form<Program> form = Form.form(Program.class,Program.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Program object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Program.update(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return ok(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error updating object"), e);
return internalServerError("Error updating object");
} finally {
Ebean.endTransaction();
}
}
示例6: create
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result create() {
// Get the form from the request
Form<Allocation> form = Form.form(Allocation.class,Allocation.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Allocation object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Allocation.create(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return created(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error creating object"), e);
return internalServerError("Error creating object");
} finally {
Ebean.endTransaction();
}
}
示例7: update
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result update(Long id) {
// Get the form from the request
Form<Allocation> form = Form.form(Allocation.class,Allocation.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Allocation object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Allocation.update(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return ok(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error updating object"), e);
return internalServerError("Error updating object");
} finally {
Ebean.endTransaction();
}
}
示例8: create
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result create() {
// Get the form from the request
Form<CourseSession> form = Form.form(CourseSession.class,CourseSession.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
CourseSession object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
CourseSession.create(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return created(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error creating object"), e);
return internalServerError("Error creating object");
} finally {
Ebean.endTransaction();
}
}
示例9: update
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result update(Long id) {
// Get the form from the request
Form<CourseSession> form = Form.form(CourseSession.class,CourseSession.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
CourseSession object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
CourseSession.update(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return ok(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error updating object"), e);
return internalServerError("Error updating object");
} finally {
Ebean.endTransaction();
}
}
示例10: clearAllData
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result clearAllData () {
String createDdl = "";
String dropDdl = "";
String evolutionContent;
try {
byte[] encoded = Files.readAllBytes(Paths.get(Play.application().path().getPath() + "/conf/evolutions/default/1.sql"));
evolutionContent = new String(encoded, "UTF-8");
String[] splittedEvolutionContent = evolutionContent.split("# --- !Ups");
String[] upsDowns = splittedEvolutionContent[1].split("# --- !Downs");
createDdl = upsDowns[0];
dropDdl = upsDowns[1];
Ebean.execute(Ebean.createCallableSql(dropDdl));
Ebean.execute(Ebean.createCallableSql(createDdl));
return ok();
} catch (Exception e) {
appLogger.error("Error clearing db data", e);
return internalServerError("Error clearing db data");
}
}
示例11: create
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result create() {
// Get the form from the request
Form<Record> form = Form.form(Record.class,Record.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Record object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Record.create(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return created(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error creating object"), e);
return internalServerError("Error creating object");
} finally {
Ebean.endTransaction();
}
}
示例12: update
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result update(Long id) {
// Get the form from the request
Form<Record> form = Form.form(Record.class,Record.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Record object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Record.update(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return ok(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error updating object"), e);
return internalServerError("Error updating object");
} finally {
Ebean.endTransaction();
}
}
示例13: create
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result create() {
// Get the form from the request
Form<Student> form = Form.form(Student.class,Student.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Student object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Student.create(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return created(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error creating object"), e);
return internalServerError("Error creating object");
} finally {
Ebean.endTransaction();
}
}
示例14: update
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result update(Long id) {
// Get the form from the request
Form<Student> form = Form.form(Student.class,Student.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Student object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Student.update(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return ok(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error updating object"), e);
return internalServerError("Error updating object");
} finally {
Ebean.endTransaction();
}
}
示例15: create
import com.avaje.ebean.Ebean; //导入依赖的package包/类
public static Result create() {
// Get the form from the request
Form<Course> form = Form.form(Course.class,Course.creation.class).bindFromRequest();
// Validate errors
if(form.hasErrors()) {
return badRequest(form.errorsAsJson());
}
// Get the object from the form
Course object = form.get();
// Create the object in db
Ebean.beginTransaction();
try {
Course.create(object);
JsonNode jsonObject = object.jsonSerialization();
Ebean.commitTransaction();
return created(jsonObject);
} catch (Exception e) {
appLogger.error(Messages.get("Error creating object"), e);
return internalServerError("Error creating object");
} finally {
Ebean.endTransaction();
}
}