Mongodb 级联删除查询操作
ObjRelationPojo表一条记录
public class YpObjRelationPojo implements Serializable {
@Id
private String id; // '主键id'
@Field("sourceid")
private String sourceId; //对象id
@Field("targetid")
private String targetId; //对象id
@Field("caseId")
private String caseId; //案件id
@Transient //配置透明属性
private int source; // '关系起点 不存数据库
@Transient
private int target; // '关系终点 不存数据库
@Transient
private String color;
@Transient
private String relation; // '关系名称'
@Field("relation_type")
@DBRef
private YpRelationTypePojo relation_type;
@Field("create_time")
private Date create_Time; // '创建时间'
省略了set,get方法
@DBRef用于关联对象
{
"_id" : ObjectId("54a24e8a25600d768a4e13ac"),
"sourceid" : "54a20a6dd9d886078991aa98",
"targetid" : "54a209dfd9d886078991aa95",
"caseId" : "100",
"relation_type" : {
"$ref" : "relationtype",
"$id" : ObjectId("54a21b0ad9d886078991aa9e")
}
}
如果需要查找出这条记录中的relation_type,查看相关联的对象
我们需要使用点表示法则
Id为relation_type表的记录id
ObjectId objectId = new ObjectId(Id);
Query query1=Query.query(Criteria.where("relation_type.$id").is(objectId));
List<YpObjRelationPojo> r=mongoTemplate.find(query1, YpObjRelationPojo.class, "YpObjRelationPojo");
找出之后,删除该字段
Update update=new Update();
update.unset("relation_type");
Mongodb 级联删除查询操作的更多相关文章
- python数据库-mongoDB的高级查询操作(55)
一.MongoDB索引 为什么使用索引? 假设有一本书,你想看第六章第六节讲的是什么,你会怎么做,一般人肯定去看目录,找到这一节对应的页数,然后翻到这一页.这就是目录索引,帮助读者快速找到想要的章节. ...
- iOS CoreData 的级联删除等操作
关于CoreData 的基本操作在网上有一些中文资料,但是这些资料大多没有涉及CoreData的详细操作,只是简单的演示了最基本用法.像级联删除这种最基本的数据库操作都没有提到.今天在网上看到了一些英 ...
- MongoDB的模糊查询操作(类关系型数据库的 like 和 not like)
1.作用与语法描述 作用: 正则表达式是使用指定字符串来描述.匹配一系列符合某个句法规则的字符串.许多程序设计语言都支持利用正则表达式进行字符串操作.MongoDB 使用 $regex 操作符来设置匹 ...
- Xamarin.Android 入门实例(4)之实现对 SQLLite 进行添加/修改/删除/查询操作
1.Main.axml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns: ...
- 第一篇:一天学会MongoDB数据库之Python操作
本文仅仅学习使用,转自:https://www.cnblogs.com/suoning/p/6759367.html#3682005 里面新增了如果用用Python代码进行增删改查 什么是MongoD ...
- MongoDB API和python操作
安装 下载mongodb的版本,两点注意 根据业界规则,偶数为稳定版,如1.6.X,奇数为开发版,如1.7.X 32bit的mongodb最大只能存放2G的数据,64bit就没有限制 到官网,选择合适 ...
- mongodb_查询操作使用_条件查询、where子句等(转)
<?php /* mongodb_查询操作使用_条件查询.where子句等(转并学习) 1.find()/findOne() mongodb数据库的查询操作即使用find()或者findO ...
- spring mongodb增删改查操作
添加数据 School @Id @GeneratedValue private long id; @Indexed(unique = true) private String name; studen ...
- 【JPA 级联保存/级联删除】@OneToMany (双向) 一对多【转】
[http://blog.sina.com.cn/s/blog_625d79410101dbdd.html] 看过前两篇帮助文档 [JPA] @OneToOne 单向 和 [JPA]@OneToO ...
随机推荐
- Japan
Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Jap ...
- cigarettes
描述 Tom has many cigarettes. We hypothesized that he has n cigarettes and smokes them one by one keep ...
- 自定义uiview 当没有数据的时候 显示自定义的uiview界面
// // ZSDTJNoDataView.h // ZSDTJNoDataView // // Created by Mac on 14-12-28. // Copyright (c) 2014年 ...
- jquery plugins —— datatables 搜索后汇总
网上的例子 http://datatables.club/example/plug-ins/api.html只能对当前页面或所有数据进行汇总,不能对搜索结果数据汇总. 以下是对datatables自带 ...
- Python中的内置函数
2.1 Built-in Functions The Python interpreter has a number of functions built into it that are alway ...
- GSS1 spoj 1043 Can you answer these queries I 最大子段和
今天下午不知道要做什么,那就把gss系列的线段树刷一下吧. Can you answer these queries I 题目:给出一个数列,询问区间[l,r]的最大子段和 分析: 线段树简单区间操作 ...
- MVC Action,Service中筛选int 和list<int>
action: public ActionResult DeleteByID(int id) { this.MessageService.DeleteMailTemplate(id); var fro ...
- backbone.Model 源码笔记
backbone.Model backbone的model(模型),用来存储数据,交互数据,数据验证,在view里面可以直接监听model来达到model一改变,就通知视图. 这个里面的代码是从bac ...
- 【CSS3】---层模型position之fixed固定定位、absolute绝对定位和relative相对定位
什么是层模型? 什么是层布局模型?层布局模型就像是图像软件PhotoShop中非常流行的图层编辑功能一样,每个图层能够精确定位操作,但在网页设计领域,由于网页大小的活动性,层布局没能受到热捧.但是在网 ...
- SQL Server 2008安装失败问题以及解决办法
一.检测过程中重启失败解决办法 在键盘上按下组合键[Win]+[R],调出运行窗口. 在窗口中输入“regedit”,点击确定,打开注册表管理界面. 在注册表左侧目录栏中找到如下位置:“HKEY_LO ...