你应该知道的springboot mongodb jpa那些小tip.

官方文档https://docs.spring.io/spring-data/data-mongodb/docs/current/reference/html/index.html

查询:

***************************************************************************

mongoTemple查询和修改

@Autowired
MongoTemplate mongoTemp;

Criteria criteria = Criteria.where(“name”).regex(“www”).andOperator(Criteria.where(“creatTime”).gte(new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).parse(“2018-06-20 21:48:54”)));
mongoTemp.find(new Query(criteria), Movie.class);

**************************************************************************

List findByName(String name);

List findByNameAndAge(String name,String age);

long countByName(String name);

原生查询语句

@Query(value=”{‘$and’:[{‘name’:{‘$regex’:?0}}]}”)
public List findByName(String name);

《你应该知道的springboot mongodb jpa那些小tip.》
《你应该知道的springboot mongodb jpa那些小tip.》
《你应该知道的springboot mongodb jpa那些小tip.》
《你应该知道的springboot mongodb jpa那些小tip.》
KeyWord可以用and方法连起来。

例如:

List findFirst5ByActivityIdInAndEndTimeAfterAndStatus(List activityIds, Date endTime,String status);

删除:
`~~~
List deleteByLastname(String lastname);

Long deletePersonByLastname(String lastname);




**上面的这些面试题都整理成了PDF文档,希望能帮助到你面试前的复习并找到一个好的工作,相对来说也节省了你在网上搜索资料的时间来学习!!!**

**附欢迎关注我的公种号:it资源之家 ,扫描下面二维码即可领取更多一线大厂Java面试题资料!**

![](https://img2020.cnblogs.com/other/1843904/202004/1843904-20200429170543685-1716669.png)

## 最后

**欢迎大家评论区一起交流,相互提升;整理资料不易,如果喜欢文章记得点个赞哈,感谢大家支持!!!**
点赞