Einfaches CRUD-Tutorial zu Play Framework und MySQL mit Ebean?

Ich bin neu bei Play Framework. Ich habe angefangen, es zu lernen und bis jetzt genieße ich es. Ich habe angefangen, Java zu lernen.

Ich habe meinen Controller und mein Modell wie folgt eingerichtet:

Regler

package controllers;

import play.mvc.Controller;
import play.mvc.Result;

//Import Product model
import models.Product;

public class Products extends Controller{


    /**
     * List all Products
     */
    public static Result list(){
        Object allProducts = Product.findAll();
        return ok((Content) allProducts); //return all products
    }
}

Modell

package models;

import java.util.List;
import play.db.*;

import play.api.db.DB;

import com.avaje.ebean.Ebean;
import com.avaje.ebean.Query;

public class Product {

    public int id;
    public String name;
    public String description;

    public Product(){

    }

    public Product(int id, String name, String description){
        this.id = id;
        this.name = name;
        this.description = description;
    }

    public static  String findAll(){
        //Using ebean and MySql, fech the product table
        //and return all products
    }
}

Um die Verwendung von MySQL zu ermöglichen, habe ich die Datei /conf/application.conf bereits folgendermaßen bearbeitet:

db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/play_db?characterEncoding=UTF-8"
db.default.user=user 
db.default.password=pass
ebean.default="models.*"

Ich habe eine Datenbank "play_db" mit einer Tabelle, die wie folgt angezeigt wird:

Mein Problem ist das Abrufen aller Produkte im Produktmodell mithilfe von ebean und MySQL. Kann mir jemand bitte ein einfaches Tutorial zeigen, das Play Java in Kombination mit Ebean und MySQL verwendet? Vielen Dan

Jemand

HINWEI Übrigens verwende ich Play v.2.3.5 für Java

Antworten auf die Frage(1)

Ihre Antwort auf die Frage