Fixing Database Error
Fixing error caused in transaction due to id generation method in database
Error
Relationships
OneToMany relationship and ManyToOne relationship stores POJOs in separate tables which are tied by one table that stores the relationship between using their respective ids. (In this case I used StepLog instead of Day because I thought it might've been a more appropriate name)
Database Locking
The issue is that SQL's implementation of autogenerated ids comes from hibernate_sequence which is a global table so when a request to pull a value from the table is processed, SQL locks the entire database. So, when a step log is created, JPA requests to generate an id for the newly created steplog which causes the entire database to become locked and in turn prevent the following request to update the person_step_log table from being updated. This results in the transaction failing which rolls back all changes.
Fix
ID generation using IDENTITY
One fix was to use a separate id generation method independent of the hibernate_sequence table used to automatically generate ids. To do this, you can change the id generation method for StepLog to IDENTITY.
AutoIncreament
This enables you to use SQL's AutoIncreament feature as your id generation method.
Successful Database Write
Thus, no request is needed/made which locks the database and therefore allows the relationship to be written into the person_step_log table.