Until the last time I checked there was nothing in the JPA specification about data load, that is, some standard to insert values in the tables automatically.
Specifically Hibernate has a configuration hibernate.hbm2ddl.import_files
which allows specifying SQL files that will be executed at the time of database creation. Note that this will only work if the bank creation type is create
or create-drop
, on the property hibernate.hbm2ddl.auto
.
However, I would not recommend using this function for several reasons:
- Content is specific to each database
- The structure of the Inserts may differ from its classes
- This only works when creating the database, there is no way to update or add values
For production, a more specialized solution is better. The most basic would be to develop a routine executed at system startup and that inserts values if they do not exist.
Other than that, there are several more advanced alternatives to using databases. A few examples:
thanks for the help! Is that I saw in the Demosielle Framework there was this option, I thought there might be something native in JPA. But thanks for the clarification.
– Victor Hugo