Professional Documents
Culture Documents
Objectives:
• practice coding a Spring controller class that returns data in html format.
• use Spring templates to create parameterized html pages and html forms.
• code Spring entity classes and use spring repository to read/write data to a database.
Reqirements:
• It should contain attributes title, rating, name of person who posted the rating, date, and time
of posting. Annotate the model class with @Entity and don’t forget it needs a primary key field
annotated @Id and getters and setters for all fields.
• Create a form that allows a user to enter their name, movie title and rating (1-5).
• Create a controller with methods.
Specifying ORDER BY
If you were coding SQL you would specify ORDER BY title, date desc to get an ordered list of
movie ratings. But you are not coding SQL, Spring-JPA is generating the SQL on your behalf. To
do this you must code a method and a Object-Query annotation in the Repository interface for
movie ratings. Assuming that you used the name MovieRating, title and date the method and
@Query annotation to use is
List<MovieRating> findAllMovieRatingsOrderByTitleDateDesc();
The @Query is similar to SQL, but it is not SQL. It is a object SQL quey language called JPQL (Java
persistence query language).
1
CST438 week 1 Programming Assignment #1
create a GitHub repo for this assignment. Commit and push your code. Create a pull request and have a
team member do a review of your code on part of Assignment 1A. Comments should be entered into
the pull request. There is nothing to submit for this assignment.
For assignment 1A, you will enter into iLearn the URL of the GitHub repo and this will give your
instructor and TA access to your code and review comments.