@Column(name = "price", nullable = "true")
private Double PriceAmount ;.
直到现在我尝试了这个,我得到了例外
Caused by: <openjpa-2.1.2-SNAPSHOT-r422266:1497841 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Field "com.model.entities.jpa.Price.PriceAmount" of "com.model.entities.jpa.Price@1433836" can not be set to "null" value.
at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.insert(HandlerFieldStrategy.java:133)
at org.apache.openjpa.jdbc.meta.FieldMapping.insert(FieldMapping.java:623)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.insert(AbstractUpdateManager.java:239)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(AbstractUpdateManager.java:166)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:97)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:78)
答案 0 :(得分:0)
如果Table Columns为NULL,则JPA Columns只能设置为null。请检查数据库并进行更改。
答案 1 :(得分:0)
使用注释
@Column(insertable = false)
private String column= null;
将阻止将字段属性添加到SQL中。然后使用fielddefault值。