是否可以运行配置的Hibernate应用程序hbm2ddl.auto=update来更新生产环境中的数据库模式?
是否有更新的方式只有一些领域使用该方法的实体对象save从春数据JPA?
例如,我有一个像这样的JPA实体:
@Entity
public class User {
@Id
private Long id;
@NotNull
private String login;
@Id
private String name;
// getter / setter
// ...
}
Run Code Online (Sandbox Code Playgroud)
凭借其CRUD回购:
public interface UserRepository extends CrudRepository<User, Long> { }
Run Code Online (Sandbox Code Playgroud)
在Spring MVC中,我有一个控制器,它获取一个User对象来进行更新:
@RequestMapping(value = "/rest/user", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<?> updateUser(@RequestBody User user) {
// Assuming that user have its id and it is already stored in the database,
// and …Run Code Online (Sandbox Code Playgroud)