org.springframework.data.mapping.PropertyReferenceException: No property xxx found for type xxx
程序员文章站
2022-07-15 13:38:14
...
Query query = new Query();
query.addCriteria(Criteria.where("trade_date").lt(trade_date));
用springboot访问mongodb的数据时,有个查询是这么写的,查小于这个日期的所有数据,运行之后报错
org.springframework.data.mapping.PropertyReferenceException: No property trade found for type xxx
有的人说是因为实体类属性不支持下划线,需要把
private String trade_date;
// 改成
@Field(name = "trade_date")
private String tradeDate;
但实际上where(“trade_date”)中的trade_date不是实体类的属性名,而就是数据库字段名,所以我觉得问题不应该出在命名上。
最后我是下面这样解决了这个问题,spring-data-mongo大于小于同时使用(网上好像没有相关的说法,但问题就这样解决了)
Query query = new Query();
query.addCriteria(Criteria.where("trade_date").lt(trade_date)).gt("00000000");
上一篇: Jpa使用@Query时 报错Validation failed for query for method public abstract
下一篇: 异常java.lang.IllegalArgumentException: Validation failed for query for method public abstract
推荐阅读
-
ubuntu下安装tomcat,shutdown时报错:./catalina.sh:1:eval:/home/xxx/jdk/jre/bin/java:not found
-
Method not found: 'System.Data.Entity.ModelConfiguration.Configuration.XXX
-
【Bug解决】org.apache.ibatis.type.TypeException: The alias ‘xxxx‘ is already mapped to the value ‘xxx‘
-
Parameter 0 of method setFunctionDomainRedisTemplate in XXX required a single bean, but 2 were found
-
SpringBoot :No property xx found for type xx!
-
Property or field ‘XXX‘ cannot be found on null
-
There is no getter for property named 'xxx' in 'class java.lang.xxxx'解决办法
-
There is no getter for property named 'xxx' in 'class com.ams.ams.entity.xxx'
-
Mybatis There is no getter for property named 'XXX' in 'class java.lang.XXX
-
org.springframework.data.mapping.PropertyReferenceException: No property xxx found for type xxx