-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Student, Instructor and User Entities for PostgreSQL Migration #12071
Create Student, Instructor and User Entities for PostgreSQL Migration #12071
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some progress, let's aim to finish this soon!
- Comment out code that will cause the build to fail.
- Add User, Instructor and Student to the list of annotated classes in HibernateUtil.java
- Please keep your branch updated with the v9 branch.
// Cascade? | ||
@OneToOne | ||
@JoinColumn(name = "teamId") | ||
private Team team; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided to move this to User instead. Two reasons, firstly there is a little know "Instructors" team that is hardcoded. Secondly, this gives us the flexibility to support teams for instructors or teams with both student and instructors in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this is definitely not OneToOne. This is a ManyToOne relationship.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense!
I've decided to move this to User instead. Two reasons, firstly there is a little know "Instructors" team that is hardcoded. Secondly, this gives us the flexibility to support teams for instructors or teams with both student and instructors in the future.
I think I misunderstood the direction. Please correct me if im wrong, from the Student's POV to have this attribute (previously), we read it as Many Students belong to One Team
or One Team has Many Students
? Hmmm so confusing! And as we were briefed, we should be going for bidirectional r/s too?
Also, this is definitely not OneToOne. This is a ManyToOne relationship.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this, might want to take a look at what each annotation means and at the differences between them. For best practices, I try to follow the ones defined here: https://thorben-janssen.com/best-practices-many-one-one-many-associations-mappings/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will give it a read! 🙇🏻
As for cascades, deleting an instructor/student should not cause anything else to be deleted. Deletion should not be cascaded. |
6bb30be
to
7907786
Compare
@domlimm, before I take a look at this, please make sure the BE can be run without errors and the tables for the entities are correctly created in the db. Thanks! |
1fa227b
to
2659481
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting closer, just a few more changes and we can merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some issues but not blockers, to fix in the next PR. I will merge this first as this is a potential blocker for others.
src/main/java/teammates/common/datatransfer/InstructorPermissionRole.java
Show resolved
Hide resolved
protected Instructor() { | ||
// required by Hibernate | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing constructors for these entities
…stgreSQL Migration (TEAMMATES#12071)
* [#12048] Set up github action workflows * [#12048] v9: Skeleton implementation (#12056) * [#12048] Add isMigrated flag to course (#12063) * [#12048] Add is migrated flag to datastore account (#12070) * Temporarily disable liquibase migrations * [#12048] Create Notification Entity for PostgreSQL migration (#12061) * [#12048] Create notification DB layer for v9 migration (#12075) * [#12048] Add UsageStatistics entity and db (#12076) * Migrate GetCourseAction.java * Migrate DeleteCourseAction.java and relevant logic functions * Migrate BinCourseAction.java and its related logic functions * Update checkSpecificAccessControl functions in BinCourseAction and DeleteCourseAction classes * Migrate RestoreCourseAction and its related logic functions * Migrate UpdateCourseAction with its related logic functions * [#12048] Add Account Entity (#12087) * [#12048] Create SQL logic for CreateNotificationAction and add relevant tests for v9 migration (#12077) * [#12048] Create Student, Instructor and User Entities for PostgreSQL Migration (#12071) * [#12048] V9: Cleanup and refactor (#12090) * Edit GetCourseAction and refactor out the old datastore code * [#12048] Remove redundant InstructorRole Enum (#12091) * Fix compilation error * Update check for database to fetch from * Add unit tests for CoursesDb * [#12048] Update GetUsageStatisticsAction to include SQL entities (#12084) * Add CoursesLogicTest class * Disable failing tests * Fix compilation error * Fix Checkstyle errors * Merge branch * Change flow for updating courses. * Update updateCourse JavaDoc comment. * Update CreateCourseAction and related methods * Update GetCourseAction. * Update UpdateCourseAction * Update BinCourseAction and RestoreCourseAction * Update DeleteCourseAction * Migrate GetCourseSectionNamesAction and related methods. * Add Unit tests for Logic layer of Course. * Fix Checkstyle errors * Add unit test for GetCourseAction's execute function * Add verify for CoursesDb unit tests and use assertNull and assertNotNull * Move fetching of course to logic layer. * Fix Checkstyle errors. * Move canCreateCourse logic to logic layer. * Change *CourseAction classes to use isCourseMigrated * Fix CoursesLogic's initLogicDependencies method call * Add unit tests for GetCourseAction. * Remove commented out method. * Add minimal unit tests for BinCourseAction, DeleteCourseAction and RestoreCourseAction. * Add minimal unit tests for GetCourseSectionAction and UpdateCourseAction. * Remove unused EntityType parameter. * Add minimal unit tests for CreateCourseAction. * Fix Checkstyle errors. * Ignore all old datastore test cases for *CourseAction classes. * Fix 'text' type to 'test'. * Change binCourseToRecycleBin to return the binned course. * Update moveCourseToRecycleBin test. * Update test name. --------- Co-authored-by: Samuel Fang <samuelfangjw@gmail.com> Co-authored-by: dao ngoc hieu <53283766+daongochieu2810@users.noreply.github.com> Co-authored-by: Samuel Fang <60355570+samuelfangjw@users.noreply.github.com> Co-authored-by: wuqirui <53338059+hhdqirui@users.noreply.github.com> Co-authored-by: Dominic Lim <46486515+domlimm@users.noreply.github.com>
* [#12048] Set up github action workflows * [#12048] v9: Skeleton implementation (#12056) * [#12048] Add isMigrated flag to course (#12063) * [#12048] Add is migrated flag to datastore account (#12070) * Temporarily disable liquibase migrations * [#12048] Create Notification Entity for PostgreSQL migration (#12061) * [#12048] Create notification DB layer for v9 migration (#12075) * [#12048] Add UsageStatistics entity and db (#12076) * Migrate GetCourseAction.java * Migrate DeleteCourseAction.java and relevant logic functions * Migrate BinCourseAction.java and its related logic functions * Update checkSpecificAccessControl functions in BinCourseAction and DeleteCourseAction classes * Migrate RestoreCourseAction and its related logic functions * Migrate UpdateCourseAction with its related logic functions * [#12048] Add Account Entity (#12087) * [#12048] Create SQL logic for CreateNotificationAction and add relevant tests for v9 migration (#12077) * [#12048] Create Student, Instructor and User Entities for PostgreSQL Migration (#12071) * [#12048] V9: Cleanup and refactor (#12090) * Edit GetCourseAction and refactor out the old datastore code * [#12048] Remove redundant InstructorRole Enum (#12091) * Fix compilation error * Update check for database to fetch from * Add unit tests for CoursesDb * [#12048] Update GetUsageStatisticsAction to include SQL entities (#12084) * Add CoursesLogicTest class * Disable failing tests * Fix compilation error * Fix Checkstyle errors * Merge branch * Change flow for updating courses. * Update updateCourse JavaDoc comment. * Update CreateCourseAction and related methods * Update GetCourseAction. * Update UpdateCourseAction * Update BinCourseAction and RestoreCourseAction * Update DeleteCourseAction * Migrate GetCourseSectionNamesAction and related methods. * Add Unit tests for Logic layer of Course. * Fix Checkstyle errors * Add unit test for GetCourseAction's execute function * Add verify for CoursesDb unit tests and use assertNull and assertNotNull * Move fetching of course to logic layer. * Fix Checkstyle errors. * Move canCreateCourse logic to logic layer. * Change *CourseAction classes to use isCourseMigrated * Fix CoursesLogic's initLogicDependencies method call * Add unit tests for GetCourseAction. * Remove commented out method. * Add minimal unit tests for BinCourseAction, DeleteCourseAction and RestoreCourseAction. * Add minimal unit tests for GetCourseSectionAction and UpdateCourseAction. * Remove unused EntityType parameter. * Add minimal unit tests for CreateCourseAction. * Fix Checkstyle errors. * Ignore all old datastore test cases for *CourseAction classes. * Fix 'text' type to 'test'. * Change binCourseToRecycleBin to return the binned course. * Update moveCourseToRecycleBin test. * Update test name. --------- Co-authored-by: Samuel Fang <samuelfangjw@gmail.com> Co-authored-by: dao ngoc hieu <53283766+daongochieu2810@users.noreply.github.com> Co-authored-by: Samuel Fang <60355570+samuelfangjw@users.noreply.github.com> Co-authored-by: wuqirui <53338059+hhdqirui@users.noreply.github.com> Co-authored-by: Dominic Lim <46486515+domlimm@users.noreply.github.com>
* [#12048] Set up github action workflows * [#12048] v9: Skeleton implementation (#12056) * [#12048] Add isMigrated flag to course (#12063) * [#12048] Add is migrated flag to datastore account (#12070) * Temporarily disable liquibase migrations * [#12048] Create Notification Entity for PostgreSQL migration (#12061) * [#12048] Create notification DB layer for v9 migration (#12075) * [#12048] Add UsageStatistics entity and db (#12076) * Migrate GetCourseAction.java * Migrate DeleteCourseAction.java and relevant logic functions * Migrate BinCourseAction.java and its related logic functions * Update checkSpecificAccessControl functions in BinCourseAction and DeleteCourseAction classes * Migrate RestoreCourseAction and its related logic functions * Migrate UpdateCourseAction with its related logic functions * [#12048] Add Account Entity (#12087) * [#12048] Create SQL logic for CreateNotificationAction and add relevant tests for v9 migration (#12077) * [#12048] Create Student, Instructor and User Entities for PostgreSQL Migration (#12071) * [#12048] V9: Cleanup and refactor (#12090) * Edit GetCourseAction and refactor out the old datastore code * [#12048] Remove redundant InstructorRole Enum (#12091) * Fix compilation error * Update check for database to fetch from * Add unit tests for CoursesDb * [#12048] Update GetUsageStatisticsAction to include SQL entities (#12084) * Add CoursesLogicTest class * Disable failing tests * Fix compilation error * Fix Checkstyle errors * Merge branch * Change flow for updating courses. * Update updateCourse JavaDoc comment. * Update CreateCourseAction and related methods * Update GetCourseAction. * Update UpdateCourseAction * Update BinCourseAction and RestoreCourseAction * Update DeleteCourseAction * Migrate GetCourseSectionNamesAction and related methods. * Add Unit tests for Logic layer of Course. * Fix Checkstyle errors * Add unit test for GetCourseAction's execute function * Add verify for CoursesDb unit tests and use assertNull and assertNotNull * Move fetching of course to logic layer. * Fix Checkstyle errors. * Move canCreateCourse logic to logic layer. * Change *CourseAction classes to use isCourseMigrated * Fix CoursesLogic's initLogicDependencies method call * Add unit tests for GetCourseAction. * Remove commented out method. * Add minimal unit tests for BinCourseAction, DeleteCourseAction and RestoreCourseAction. * Add minimal unit tests for GetCourseSectionAction and UpdateCourseAction. * Remove unused EntityType parameter. * Add minimal unit tests for CreateCourseAction. * Fix Checkstyle errors. * Ignore all old datastore test cases for *CourseAction classes. * Fix 'text' type to 'test'. * Change binCourseToRecycleBin to return the binned course. * Update moveCourseToRecycleBin test. * Update test name. --------- Co-authored-by: Samuel Fang <samuelfangjw@gmail.com> Co-authored-by: dao ngoc hieu <53283766+daongochieu2810@users.noreply.github.com> Co-authored-by: Samuel Fang <60355570+samuelfangjw@users.noreply.github.com> Co-authored-by: wuqirui <53338059+hhdqirui@users.noreply.github.com> Co-authored-by: Dominic Lim <46486515+domlimm@users.noreply.github.com>
Part of #12048.
Outline
This PR creates the new Student and Instructor Entity to be used for PostgreSQL Migration.
Below are the findings for the 4 available inheritance strategies in Hibernate:
MappedSuperclass
Single Table
Joined Table aka Table-per-subclass mapping strategy (This has been selected)
Table per Class