I've run into an issue where we are updating an existing JPA project while needing to maintain backwards support. I have a relationship table that models a relationship from entity A to entity B.

The relationship table has a from and to id that are represented as strings and previously all the one to one mapping for each entity was managed through application code rather than in the entity using the proper annotations.

The previous application clients need to retain the ability to write JPQL statements to these string fields. I was wondering if there was any way to in place convert these to enforcing one to one mapping via a foreign key constraint since JPA normally requires the entity rather than using a string key.

Thanks in advance! Please let me know if more explanation is required.