I am using play for the first time and am stuck in a maze. I am trying to store the value of top and left in the db along with the product name. I have managed to get pass the values to the controller but am not sure how to store it from there.
//controller
@BodyParser.Of( play.mvc.BodyParser.Json.class )
public static Result myMethod(){
response().setContentType( "application/json" );
JsonNode json = request().body().as(JsonNode.class);
JsonNode jsonRequest = request().body().asJson();
//left and top
Double left= jsonRequest.findPath("Left").asDouble();
Double top= jsonRequest.findPath("Top").asDouble();
ObjectNode result = Json.newObject();
System.out.println("left " +left+"\ntop "+top);
result.put("status", "OK");
return ok(result);
}
This is my db schema
@Entity
public class Position extends Model {
@Id
public long id;
@Required
public long left;
@Required
public long top;
public static Finder<Long,Position> find = new Finder<Long,Position>(Long.class, Layout.class);
}
How do I save it using ebeans???