作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我的项目是用spring data mongodb开发的,以前有这个文档:
@Document(collection="Instrument")
public class Instrument {
@Id
private Integer id;
private String name;
private String internalCode;
private String fosMarketId;
private String localCode;
//setters...getters... and constructurs....
现在我需要向我的文档添加一些属性,如下所示:
....
private Long from;
private Long to;
private Long OpenHourfrom;
private Long OpenHourTo;
private Boolean isActive;
//setters...getters... and constructurs....
所以我有了这个新的构造函数:
@PersistenceConstructor
public Instrument(Integer id, String name, String internalCode, String fosMarketId, String localCode, Long from,
Long to, Long openHourfrom, Long openHourTo, Boolean isActive) {
super();
this.id = id;
this.name = name;
this.internalCode = internalCode;
this.fosMarketId = fosMarketId;
this.localCode = localCode;
this.from = from;
this.to = to;
this.OpenHourfrom = openHourfrom;
this.OpenHourTo = openHourTo;
this.isActive = isActive;
}
但是当我运行其中一个 repo 方法时,这个异常被抛出:
org.springframework.data.mapping.model.MappingException: No property openHourfrom found on entity class com.tosan.entity.Instrument to bind constructor parameter to!
at org.springframework.data.mapping.model.PersistentEntityParameterValueProvider.getParameterValue(PersistentEntityParameterValueProvider.java:74)
at ....
请注意,我使用带有以下设置的 spring-confix.xml:
<mongo:mongo-client
host="IP" port="Port" >
<mongo:client-options write-concern="NORMAL"
connections-per-host="1000"
threads-allowed-to-block-for-connection-multiplier="600"
connect-timeout="10000"
max-wait-time="15000"
socket-keep-alive="true"
socket-timeout="15000"
/>
</mongo:mongo-client>
我想知道如何将 hibernate spring 的自动更新属性设置为 true,以便我可以更新我的文档并添加新属性。
最佳答案
使用import org.springframework.data.mongodb.core.mapping.Field;
@Field
每个字段的注释
检查实体类的构造函数并确保参数名称正确
关于java - 映射异常 : "No property found on entity to bind constructor parameter to"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47387143/
我是一名优秀的程序员,十分优秀!