springboot mongodb jpa常用方法整理
官方文档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<User> findByName(String name);
List<User> findByNameAndAge(String name,String age);
long countByName(String name);
原生查询语句
@Query(value="{'$and':[{'name':{'$regex':?0}}]}")
public List<Movie> findByName(String name);
| Keyword | Sample | Logical result |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KeyWord可以用and方法连起来。
例如:
List<DiscountCode> findFirst5ByActivityIdInAndEndTimeAfterAndStatus(List<ObjectId> activityIds, Date endTime,String status);
删除:
List <Person> deleteByLastname(String lastname);
Long deletePersonByLastname(String lastname);
springboot mongodb jpa常用方法整理的更多相关文章
- springboot整合JPA(简单整理,待续---)
整合步骤 引入依赖: <dependencies> <dependency> <groupId>org.springframework.boot</group ...
- Springboot+Atomikos+Jpa+Mysql实现JTA分布式事务
1 前言 之前整理了一个spring+jotm实现的分布式事务实现,但是听说spring3.X后不再支持jotm了,jotm也有好几年没更新了,所以今天整理springboot+Atomikos+jp ...
- 【极简版】SpringBoot+SpringData JPA 管理系统
前言 只有光头才能变强. 文本已收录至我的GitHub仓库,欢迎Star:https://github.com/ZhongFuCheng3y/3y 在上一篇中已经讲解了如何从零搭建一个SpringBo ...
- 带你搭一个SpringBoot+SpringData JPA的环境
前言 只有光头才能变强. 文本已收录至我的GitHub仓库,欢迎Star:https://github.com/ZhongFuCheng3y/3y 不知道大家对SpringBoot和Spring Da ...
- 二、springboot使用jpa
花了几天时间,好好看了看springboot的jpa部分,总结了常用的形式. 1.通过STS工具添加jpa的依赖项 要连mysql,测试的时候需要web,顺便添加了lombok不写set和get方法了 ...
- Python 部分系统类的常用方法整理
下面是常用的几个系统类的常用方法整理: list: 列表[1, 2,...] set: 集合,无重复元素{1, 2,...} str: 字符串 dict: 字典{a:'a', b:'b',...} T ...
- Springboot+MyBatis+JPA集成
1.前言 Springboot最近可谓是非常的火,本人也在项目中尝到了甜头.之前一直使用Springboot+JPA,用了一段时间发现JPA不是太灵活,也有可能是我不精通JPA,总之为了多学学Sp ...
- 【第十二章】 springboot + mongodb(复杂查询)
简单查询:使用自定义的XxxRepository接口即可.(见 第十一章 springboot + mongodb(简单查询)) 复杂查询:使用MongoTemplate以及一些查询条件构建类(Bas ...
- 第12章—使用NoSQL数据库—使用MongoDB+Jpa操作数据库
使用MongoDB+Jpa操作数据库 SpringData还提供了对多种NoSQL数据库的支持,包括MongoDB;neo4j和redis.他不仅支持自动化的repository,还支持基于模板的数据 ...
随机推荐
- SpringBoot2.X&Prometheus使用
1.启动Prometheus [root@ip101 prometheus-2.12.0.linux-amd64]# pwd /opt/app/prometheus-2.12.0.linux-amd6 ...
- mysql 查看库结构---查看表结构
查看库结构:SHOW DATABASES; 查看表结构: show tables即为显示当前数据库中所有的表.又如: mysql> use dbname //进入dbname库Database ...
- 八十九:redis之python操作redis
安装:pip install redis 连接 字符串操作 插入值 获取 删除值 列表操作,更多操作见源码 添加 获取 集合操作,更多操作见源码 哈希操作,更多操作见源码 事务操作:cache.pip ...
- Eclipse 设置护眼背景色
Eclipse 设置护眼背景色 1.设置字体大小 Window --> Preferences --> General --> Apprearance --> Colors a ...
- SQL Server 等待统计信息基线收集
背景 我们随时监控每个服务器不同时间段的wait statistics ,可以根据监控信息大概判断什么时候开始出现异常,相当于一个wait statistics基线收集,还可以具体分析占比高的等待类型 ...
- python网络编程(Socket、TCP、UDP)
Socket 是网络编程的一个抽象概念,通常我们用一个Socket表示 "打开了一个网络链接",而打开一个Socket 需要知道目标计算机的IP 地址和端口号,再指定协议类型即可. ...
- “vmware 未能初始化监视器设备”的解决方法
从挂起状态唤醒时出现"vmware 未能初始化监视器设备"的提示,在cmd中输入命令 net start vmci net start vmx86 可能还不能成功启动,提示&quo ...
- Python基础知识(程序结构)
流程控制语句 选择语句.条件表达式.循环语句.跳转语句.pass空语句 程序结构三种基本结构 顺序结构.选择结构.循环结构 顺序结构 按照代码顺序依次运行 选择结构 根据条件表达式结果选择执行不同的语 ...
- 积累-T
emmm,各种知识点都有吧,主要方便自己记 随机修改网页图标 <script> var image=new Array(3); image.length=3; image[1]=" ...
- FTP简单搭建(二)
六.配套设置 1.基于用户名的上传和下载 创建用户 useradd alex echo redhat |passwd --stdin alex 指定用户登录的路径 可不设置,不设置则为用户家目录 mk ...