Proceedings to updated entities using jhipster
Here is the development workflow:
./mvnw liquibase:diff
(or ./mvnw compile liquibase:diff
to compile before)src/main/resources/config/liquibase/changelog
directorysrc/main/resources/config/liquibase/master.xml
file, so it is applied the next time you run your applicationIf you use Gradle instead of Maven, you can use the same workflow by running ./gradlew liquibaseDiffChangelog -PrunList=diffLog
,
and change the database configuration in build.gradle in the liquibase configuration if required.
There are 2 main options to create/edit an entity. It is possible to use jhipster's entity manager or create/edit and import an jhioster .jdl using JDLStudio.
jhipster import-jdl {filename}
Follow JHipster inscrutions about how to use the tool.
Once the editing process is completed, it is neecessary to address the database changes on liquibase. It is important to notice that jhipster doesn't manage this kind of database change automatically.
You must decide if it is necessary to migrate the database or if it may be dropped.
To migrate the database, it is necessary to create a liquibase changelog, to inform liquibase about database changes, making the appropriate modification, like inserting standard values in certain fields.
./gradlew liquibaseDiffChangeLog
src\main\resources\config\liquibase\changelog
master.xml
, located on src\main\resources\config\liquibase\
master.xml
Considering that the database was changed using some of the jhipster system, call on terminal
./gradlew clean
to wipe out the data./gradlew liquibaseClearChecksums
to clear liquibase checksums, validating the changed changelogsWhen using cache, it may be necessary to update CacheConfiguration.java
, including new entities and its foreign keys.
Notice the @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
annotation in the entity class.
@ApiModel(description = "Pesquisa completa")
@Entity
@Table(name = "pesquisa")
\!h // using cache for entity
\!h @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Pesquisa implements Serializable {
@OneToMany(mappedBy = "pesquisa")
@JsonIgnore
\!h // using cache for foreign key
\!h @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<AgeGroup> ageGroup = new HashSet<>();
}
The cache configuration must be updated.
@Configuration
@EnableCaching
@AutoConfigureAfter(value = { MetricsConfiguration.class })
@AutoConfigureBefore(value = { WebConfigurer.class, DatabaseConfiguration.class })
public class CacheConfiguration {
// ...
@Bean
public JCacheManagerCustomizer cacheManagerCustomizer() {
return cm -> {
// ...
\!h cm.createCache(br.com.pixinside.arcelor.linhadotempo.futuro.domain.Pesquisa.class.getName(), jcacheConfiguration);
\!h cm.createCache(br.com.pixinside.arcelor.linhadotempo.futuro.domain.Pesquisa.class.getName() + ".ageGroup", jcacheConfiguration);
// ...
}
}