我有一個Spring引導應用程序+ JPA與MySQL。在我的控制器中,當我發佈實體時,我可以調用repository.save,並返回「創建/更新」對象。Spring存儲庫+ JPA + Hibernate沒有提交當repository.save
但是,當我看着數據庫,我看到該對象不更新。
這裏是我的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
你知道還有什麼我有什麼關係?
這是我的控制器:
@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);
}
而且MyEntityService:
@Override
@UserCanCud
public Entity save(final Entity entity) {
Assert.notNull(entity);
final Entity savedEntity = repository.save(entity);
return savedEntity;
}
添加它調用控制器方法保存 –
已編輯。我希望這是明確的 – Manuelarte
您的交易邊界在哪裏? –