Question: is there a common pattern in Java to avoid mongoDB injection attacks?

Thanks

Answer: 
You can build MongoDB querys with Javascript in the where clause and here injection can happen. Here explanation how to prevent this: <https://docs.mongodb.com/manual/faq/fundamentals/#how-does-mongodb-address-sql-or-query-injection>
yes there is, by using regex search.
Ex: lets say you do check by username and you are not using EQ op.
If i pass [a-z] for example i will bypass your login action :).

But anyway, it very much depends on the logic of how things are implemented in the solution.