[x] There is an @Entity class called PersonalSchedules.java
[x] There is a @Repository class called PersonalSchedulesRepository.java
[ ] When you start up the repo on localhost, you can see the table
using the H2 console (see the file docs/h2-database.md for
instructions.)
[ ] When you deploy the app to Heroku, you can see the table
using the psql command (See Accessing Database Console in the
main README.md file for instructions.)
You may also want to consult User.java in the same repo for another example.
Your file will be called PersonalSchedules.java and should be placed
in the entities subdirectory of the repo.
It will have a field for id, which should be defined like this:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
And fields for name,description, and quarter. IMPORTANT NOTE FROM NICK - I'm not sure if 'quarter' should be a String or an int, so unless you are sure, you should double check.
Note that one of the suprising things about Spring Boot is that
you do not need to write code for these methods. Instead, the
part of the Spring Boot framework known as Spring Data JDBC
looks at the name you choose for these methods
and based on that, it writes them for you.
The rules for translating method naming conventions into
generated code are complicated: we will not go over all of them in lecture, and you are not expected to memorize or learn them all.
Instead, you need to be able to find what you need, when you need it.
While in this case, we are telling you what methods to add,
in future cases, you'll be expected to figure out from context
what kinds of lookup methods you might need for a table, consult
the Spring Data
Create database table for PersonalSchedules
Acceptance Criteria:
@Entity
class called PersonalSchedules.java@Repository
class called PersonalSchedulesRepository.javadocs/h2-database.md
for instructions.)Accessing Database Console
in the mainREADME.md
file for instructions.)Details:
@Entity
classThe
@Entity
class should be similar to the fileTodo.java
in the example repo https://github.com/ucsb-cs156-w22/demo-spring-react-example-v2.You may also want to consult
User.java
in the same repo for another example.Your file will be called
PersonalSchedules.java
and should be placed in theentities
subdirectory of the repo.It will have a field for
id
, which should be defined like this:And fields for
name
,description
, andquarter
. IMPORTANT NOTE FROM NICK - I'm not sure if 'quarter' should be a String or an int, so unless you are sure, you should double check.Also note that the line:
should be replaced with this, since Spring Boot requires
CamelCase
while SQL requiressnake_case
:The rest, you should be able to figure out on your own.
Note:
This preceeds the attribute:
which is how we indicate that a particular record belongs to a particular
User
.Details:
@Repository
classFor the repository class, see the example
TodoRepository.java
.You may also consult
UserRepository.java
in the same repo for another example.Looking at the sample code, let's figure out what needs to be changed:
TodoRepository
toPersonalScheduleRepository
Todo
toPersonalSchedule
. ThisTodo
refers back to the@Entity
class for a single row in the database.You'll need to replace the method:
With these:
Note that one of the suprising things about Spring Boot is that you do not need to write code for these methods. Instead, the part of the Spring Boot framework known as Spring Data JDBC looks at the name you choose for these methods and based on that, it writes them for you.
The rules for translating method naming conventions into generated code are complicated: we will not go over all of them in lecture, and you are not expected to memorize or learn them all. Instead, you need to be able to find what you need, when you need it.
Some documentation is here to help get you started: https://docs.spring.io/spring-data/jdbc/docs/current/reference/html/#jdbc.query-methods
While in this case, we are telling you what methods to add, in future cases, you'll be expected to figure out from context what kinds of lookup methods you might need for a table, consult the Spring Data