JPA 主鍵問題,添加實體時報錯 Field '' doesn't have a default value

添加實體對象時報錯:Field '' doesn't have a default valuejava

@TableGenerator(name = "ID_GENERATOR", table = "omg_id_generator", allocationSize = 1, pkColumnName = "name", 
			pkColumnValue = "user_id", valueColumnName = "value")
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "ID_GENERATOR")
	@Id
	public Integer getUserId() {
		return userId;
	}

 

此處的解決方法:數據庫

一般刪除對應的Table從新建立便可。框架

緣由:code

一般是因爲建立Table以後對Entity或者ORM作了相應的修改,致使ORM框架(Hibernate)不能正常進行數據庫表或schema進行映射,所以刪除重建便可。對象

相關文章
相關標籤/搜索