When I'm getting a property which doesn't exist in java object error when I do this. My record object has
@Document
public class Record{
@Field("RecordIdentifier")
String RecordIdentifier;
...
}
My MongoRepository object has
public interface RecordRepository extends MongoRepository<Record,String> {
@Query("{ 'RecordIdentifier' : ?0 }
public Record findByRecordIdentifier(String RecordIdentifier);
}
And in the MongoDB I have
{
'RecordIdentifier' : 'D'
}
But when I call the query method
@Autowired
RecordRepository repository
...
repository.findAll();
repository.findByRecordIdentifier("D");
The repository.findAll() returns fine and maps everything correctly, but findByRecordIdentifier() returns an error saying that it cannot find property 'recordIdentifier' in the Record object. If I change the name of the field from 'RecordIdentifier' to 'recordIdentifier' in the Record object it works fine but why can't I have the field be called 'RecordIdentifier'
What's really weird is if I change the Mongo document to
{
'Record_Identifier' : 'D'
}
I still get the same error even though the query should no longer be returning anything since it's now pointing to a field that doesn't exist. Could someone help me out? I can provide more details if need be.