After updating dependencies from Spring 4.1.6.RELEASE to 5.1.4.RELEASE and Hibernate 4.3.9.Final to 5.4.1.Final, some of my test cases started failing with ConstraintViolationException on the primary key.
Due to historical reasons we are generating the primary like so:
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "NAME_HERE")
@TableGenerator(name = "NAME_HERE", table = "SEQUENCE_TABLE_NAME", pkColumnName = "Name", pkColumnValue = "ENTITY_NAME", valueColumnName = "VALUE_COLUMN_NAME", allocationSize = 100)
While using the application normally it does not seem to be a problem, however when running tests it does.
I have noticed that the ConstraintViolationException only occurs for tables where multiple values are inserted within the same test case. So i'm thinking the rows are somehow assigned the same primary key.
Running the tests locally it does not seem to be a problem, so it could also have something to do with how the tests are run on the build server. However it was not a problem before upgrading dependencies.
I have checked that the sequence values are higher than the latest value in the database, but again this was not a problem before upgrading dependencies.
I am hoping to jolt someones memory :-)