I have a Spring Boot Application + JPA with MySQL. In my controller, when I post an entity I am able to call to repository.save, and I return the "created/updated" object.
But, when I look at the database, I see that the object is not updated.
Here is my application.yml:
spring:
jpa:
show-sql: true
generate-ddl: false
hibernate:
ddl-auto: none
properties:
hibernate.dialect: org.hibernate.dialect.MySQLDialect
org.hibernate.envers.store_data_at_delete: true
org.hibernate.envers.global_with_modified_flag: true
org.hibernate.envers.track_entities_changed_in_revision: true
datasource:
initialize: false
url: jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:databaseName}?createDatabaseIfNotExist=true
username: ${DB_USERNAME:root}
password: ${DB_PASSWORD:root}
driver-class-name: com.mysql.jdbc.Driver
hikari:
minimumIdle: 20
maximumPoolSize: 30
idleTimeout: 5000
data-source-properties:
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
Do you know what else do I have to do?
This is my controller:
@RequestMapping(method = RequestMethod.POST, produces = "application/json")
public MyEntity saveMyEntity(@Valid @RequestBody final MyEntity myEntity) {
Assert.notNull(myEntity, "The entry cannot be null");
return myEntityService.save(myEntity);
}
And MyEntityService:
@Override
@UserCanCud
public Entity save(final Entity entity) {
Assert.notNull(entity);
final Entity savedEntity = repository.save(entity);
return savedEntity;
}