I have a Spring Boot application accessing a database having schemata A and B, employing JPA and Hibernate, all entities but one are controlled by me (I can modify them and update their data).
Sometimes, when I restart the application, I want Hibernate to drop/create or update tables to reflect the latest modifications from the entities annotated @Entity in schema 1.
I configured the application to update the database schema and seed it with data.
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create
spring.sql.init.mode=always
spring.sql.init.data-locations=classpath:/sample.sql
spring.jpa.defer-datasource-initialization=true
All the entities controlled and seeded by me are hosted in the first schema; the entity I can not modify and seed is hosted in schema 2 (It is managed by another application).
Employing the idead borrowed from here, I was able to protect the entities from the second schema from modifications. Still, when data is loaded, the content of the table is deleted. I underline there are no statements about clearing the content in my seeding script.
How can I prevent the update of the data of the entities in the second schema?