Entity table:
Query operation:
database:
There is no problem with the operation statement, but the query is always empty. The reason is that even if @MongoId is not used to declare id as the primary key, it will still treat "id" as "_id".
In Criteria criteria = new Criteria().andOperator(Criteria.where("id").is(id)); In this operation statement, it is obvious that I want to specify the foreign key "id", "id" The value is 16, but what it actually judges is the primary key "_id" in the database, and the value of "_id" is "642942bf358c357b0f9c8d19", so the query is always empty.
The solution is very simple, change the key name of the foreign key, and the foreign key must not be named id.