-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Our app uses Spring boot 3.3.6 and have the following scenario:
Model:
@Document(collection = "STORAGE_CLASS")
public class StorageClass {
@Field("STATUS")
private String status;
@Field("FIELD_NUMBER")
private long numberField;
... // getters, setters, tostring
}
We need to query this collection on database every 10 seconds, so we wrote a dao for it:
public interface StorageClassDao {
List<StorageClass> getStorage();
}
@Repository
public class StorageClassDaoImpl implements StorageClassDao {
private MongoTemplate mongoTemplate;
public StorageClassDaoImpl(MongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate;
}
@Override
public List<StorageClass> getStorage() {
Criteria criteria = Criteria.where("STATUS").is("E")
.and("FIELD_NUMBER").is(1);
Query query = new Query(criteria);
return this.mongoTemplate.find(query, StorageClass.class);
}
}
This works, I receive data from getStorage which matches the query I passed. However I see a lot of PropertyReferenceException are being thrown (If I add a breakpoint to this exception), with the messages as follows:
- No property 'STATUS' found for type 'StorageClass'
- No property 'STATU' found for type 'StorageClass'
- No property 'STAT' found for type 'StorageClass'
- No property 'STA' found for type 'StorageClass'
- No property 'ST' found for type 'StorageClass'
- No property 's' found for type 'StorageClass'
- No property 'FIELD' found for type 'StorageClass'
- No property 'FIEL' found for type 'StorageClass'
- No property 'FIE' found for type 'StorageClass'
- No property 'FI' found for type 'StorageClass'
- No property 'f' found for type 'StorageClass'
- No property 'FIELD_NUMBER' found for type 'StorageClass'
- No property 'FIELD_NUMBE' found for type 'StorageClass'
- No property 'FIELD_NUMB' found for type 'StorageClass
- No property 'FIELD_NUM' found for type 'StorageClass'
- No property 'FIELD_NU' found for type 'StorageClass'
- No property 'FIELD_N' found for type 'StorageClass''
- No property 'FIELD_' found for type 'StorageClass'
The exceptions are throwed manly from two places:
- Exception 'org.springframework.data.mapping.PropertyReferenceException' occurred in thread 'scheduling-1' at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:490)
- Exception 'org.springframework.data.mapping.PropertyReferenceException' occurred in thread 'scheduling-1' at org.springframework.data.mapping.PropertyPath.(PropertyPath.java:94)
For every service call, more than 100 of this exceptions are being throwed. On our actual app, more than 100k exception are being throwed / GC, which is consuming a lot of unecessary resources.
What am I doing wrong here?
Code for reference: https://github.com/felipeissa/mongo-db-exception
Spring boot version: 3.3.6
Spring data mongodb version: 4.3.6
Java version: 21