Resolve hibernate database crap
The lab and assignment tables are both declared as the owner of a many to many relationship. This caused two join tables to be created one for both entities. Neither of the two tables contained the other, so this migration inserts their union into a third new table.
The composite key needs to be done through jpa compliant annotations for spring repositories to work correctly. Note that this differs from the hibernate documentation.
Spring repositories apparently code to the jpa spec not to the hibernate implementation. The way to create a composite key using JPA is to create an embeddable that you use as an @EmbeddedId. The associations then need a corresponding @MapsId to link it to the id stored in the embedded id.
There is still a lot of work to do before this lab <-> assignment dataflow is anywhere near sane. There's lots of bullshit happening with cloning of labs, updating labs through shallow clones of json and copying things over from assignments and courses.
Steps to take:
- frontend Lab updates should be mapped to a different type then the concrete entity.
- Tests should be made for the weird cases that are left over with
todos in the code.
These include:
- The resetting of labs through removing and re-adding the links
- The contains check on addings labs and assignments
- Anything that does a getter on labs or assignments that might have mutations trigger any state changes.
Geez man this shit was fucked up....