Commit 0669b164 authored by narakorn vichianchai's avatar narakorn vichianchai

การดึงข้อมูลจากฐานข้อมูล

parent 1f130707
create models Car.java form Company.java
- car еͧ import , @Entity , @Constraints.Required//躹÷ҧ
- delete conf->evolutions->default->1.sql ѹ sbt run ա駨 car sql
1. ҧ models -> Course.java
2.
@Entity
public class Course {
@Id
public Long id;
public String title;
public String description;
public static Finder<Long, Course> find = new Finder<>(Course.class);
}
<Long, Course> find = new Finder<>(Course.class);
3. conf > evolutions > 2.sql insert into course (id,title,description) values ( 1,'Numertical Method', '͹');
delete from course;
4. ҧ CourseController.java
public Result course() {
List<Course> courseList = Course.find.all();
return ok(views.html.course.render(courseList));
}
5. ҧ course.scala.html
@(courseList: List[models.Course])
ǹ㹡ѹѾ
@for(c <- courseList) {
<tr>
<td>@c.id</td>
<td>@c.title</td>
<td>@c.description</td>
</tr>
}
6. routes
GET /course controllers.CourseController.course()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment