Hi I have a Spring project and Im migrating everything from my handmade persistent layer using sql to Hibernate/JPA ORM.
I facing the following situation: I have an AbstractUser class, a SimpleUser and a ProviderUser. Simple and Provider extend form AbstractUser. What differentiates Provider from SimpleUser is that the first one has extra fields and entities the second one does not have. Im using @Inheritance(strategy = InheritanceType.SINGLE_TABLE) to map my inheritance and everything is running smoothly.
The thing is I dont know how to manage the action of upgrading a SimpleUser to a Provider. Two things come to my mind:
- Removing the entity form the database and creating a new one using the Provider implementation.
- Changing the DiscriminatorColumn value for the SimpleUser to the one that refers to Provider.
I really think neither of these ways are correct, but they work. What is the best way of doing this?