GeT_RiGhT
GeT_RiGhT

Reputation: 47

Make JPA do not change the structure of existing database

I wonder is it possible ? For example there is a constraint in my database ON DELETE SET NULL but I can't set this constraint in JPA (as I know there is not supported). So when JPA update my database it will remove this constraint (am I right?) but I won't it.

Upvotes: 0

Views: 199

Answers (2)

Neil Stockton
Neil Stockton

Reputation: 11531

Firstly, just to reiterate what others have already told you ... it is YOUR configuration that tells JPA to update the schema, and you don't share what your configuration is so nobody can say any more about it.

Secondly, you certainly CAN configure JPA to define ForeignKey constraints. To do this you make use of the "foreignKeyDefinition" attribute (of the annotation/XML element) defining the full FK info. See this link for the annotation.

Upvotes: 1

abalos
abalos

Reputation: 1361

JPA doesn't update the schema unless specifically configured to. If you don't have this set up, then you won't need to worry about JPA updating the database and removing this constraint.

Upvotes: 1

Related Questions