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.
Asked
Active
Viewed 164 times
0
-
2Why would JPA update your database schema? It won't, unless you explicitly configure it to do it. – JB Nizet Jan 11 '16 at 16:10
-
If you are using hibernate then see this: http://stackoverflow.com/questions/438146/hibernate-hbm2ddl-auto-possible-values-and-what-they-do – K.Nicholas Jan 11 '16 at 17:39
2 Answers
1
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.

abalos
- 1,301
- 7
- 12
1
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.

Neil Stockton
- 11,383
- 3
- 34
- 29