Before I executed test class EmployeeTest, I inserted one row in the table tbl_positions like this:
Because tbl_positions is a catalog and it most not be created when I create an Employee.
My problem arise when I executed the test class EmployeeTest. When I invoke the method service.createEmployee(employee), I get the exception: Duplicate entry '1' for key 'PRIMARY' referencing the table tbl_positions. This is a problem for me because what I need is that if a Position already exists, it only creates the Employee. Even better, for business constraints when I create an Employee, all the Positions must exist.
So when you attempt to create an Employee with position 1, it cascades this and attempts to create a Position with ID 1 which breaks the primary key constraint as there is already a row with this ID.
Try this instead: