spring data mongodb中,如果对象中的属性不想加入到数据库字段中,可加@Transient注解,声明为透明属性

spring data mongodb 官网帮助文档

http://www.boyunjian.com/javadoc/org.springframework.data/spring-data-mongodb/1.2.3.RELEASE/_/org/springframework/data/mongodb/core/query/Criteria.html#all(java.util.Collection

 package ywzn.by.scity.service.pojo;

 import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date; import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field; @Document(collection="YpObjRelationPojo")
@CompoundIndexes({@CompoundIndex(name="objrelation",def="{'sourceid':1,'targetid':1}")})
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; // '关系终点 不存数据库
@Field("relation")
private String relation; // '关系名称'
@Field("create_time")
private Date create_Time; // '创建时间' public YpObjRelationPojo(String id, String sourceid, String targetid,
String caseId, String relation, Date create_time) {
super();
this.Id = id;
this.sourceId = sourceid;
this.targetId = targetid;
this.caseId = caseId;
this.relation = relation;
this.create_Time = create_time;
} public YpObjRelationPojo(String id, String sourceid, String targetid,
String caseId, String relation) {
super();
this.Id = id;
this.sourceId = sourceid;
this.targetId = targetid;
this.caseId = caseId;
this.relation = relation;
} public YpObjRelationPojo() {
super();
} @Override
public String toString() {
return "YpObjRelationPojo [id=" + Id + ", sourceid=" + sourceId
+ ", targetid=" + targetId + ", caseId=" + caseId + ", source="
+ source + ", target=" + target + ", relation=" + relation
+ ", create_time=" + create_Time + "]";
} /**
* @return the id
*/
public String getId() {
return Id;
} /**
* @param id the id to set
*/
public void setId(String id) {
Id = id;
} /**
* @return the sourceId
*/
public String getSourceId() {
return sourceId;
} /**
* @param sourceId the sourceId to set
*/
public void setSourceId(String sourceId) {
this.sourceId = sourceId;
} /**
* @return the targetId
*/
public String getTargetId() {
return targetId;
} /**
* @param targetId the targetId to set
*/
public void setTargetId(String targetId) {
this.targetId = targetId;
} /**
* @return the caseId
*/
public String getCaseId() {
return caseId;
} /**
* @param caseId the caseId to set
*/
public void setCaseId(String caseId) {
this.caseId = caseId;
} /**
* @return the source
*/
public int getSource() {
return source;
} /**
* @param source the source to set
*/
public void setSource(int source) {
this.source = source;
} /**
* @return the target
*/
public int getTarget() {
return target;
} /**
* @param target the target to set
*/
public void setTarget(int target) {
this.target = target;
} /**
* @return the relation
*/
public String getRelation() {
return relation;
} /**
* @param relation the relation to set
*/
public void setRelation(String relation) {
this.relation = relation;
} /**
* @return the create_Time
*/
public Date getCreate_Time() {
return create_Time;
} /**
* @param create_Time the create_Time to set
*/
public void setCreate_Time(Date create_Time) {
this.create_Time = create_Time;
} }

spring data mongodb中,如果对象中的属性不想加入到数据库字段中的更多相关文章

  1. 如何在Spring Data MongoDB 中保存和查询动态字段

    原文: https://stackoverflow.com/questions/46466562/how-to-save-and-query-dynamic-fields-in-spring-data ...

  2. Spring Data JPA系列2:SpringBoot集成JPA详细教程,快速在项目中熟练使用JPA

    大家好,又见面了. 这是Spring Data JPA系列的第2篇,在上一篇<Spring Data JPA系列1:JDBC.ORM.JPA.Spring Data JPA,傻傻分不清楚?给你个 ...

  3. Spring Data MongoDB 五:进阶文档查询(分页、Morphia)(二)

    Spring Data MongoDB 三:基本文档查询(Query.BasicQuery)(一) 学习MongoDB 六: MongoDB查询(游标操作.游标信息)(三) 一.简单介绍 Spring ...

  4. spring data mongodb 配置遇到的几个问题

    一. mongodb 2.2版本以上的配置 spring.data.mongodb.uri = mongodb://newlook:newlook@192.168.0.109:27017/admin ...

  5. 使用Spring访问Mongodb的方法大全——Spring Data MongoDB查询指南

    1.概述 Spring Data MongoDB 是Spring框架访问mongodb的神器,借助它可以非常方便的读写mongo库.本文介绍使用Spring Data MongoDB来访问mongod ...

  6. Spring data mongodb @CreatedBy@LastModifiedBy@CreatedBy@LastModifiedBy SpringSecurityAuditorAware,只记录用户名

    要在Spring data mongodb 中使用@CreatedBy@LastModifiedBy@CreatedBy@LastModifiedBy  这四个注解 必须实现 SpringSecuri ...

  7. Spring Data MongoDB 三:基本文档查询(Query、BasicQuery)(一)

    一.简单介绍 Spring Data  MongoDB提供了org.springframework.data.mongodb.core.MongoTemplate对MongoDB的CRUD的操作,上一 ...

  8. Spring Data MongoDB 一:入门篇(环境搭建、简单的CRUD操作)

    一.简介 Spring Data  MongoDB 项目提供与MongoDB文档数据库的集成.Spring Data MongoDB POJO的关键功能区域为中心的模型与MongoDB的DBColle ...

  9. Spring Data MongoDB 三:基本文档查询(Query、BasicQuery

    一.简介 spring Data  MongoDB提供了org.springframework.data.mongodb.core.MongoTemplate对MongoDB的CRUD的操作,上一篇我 ...

随机推荐

  1. android116 轮播 viewPager实现

    布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:to ...

  2. C栈stack

    栈是一种  特殊的线性表 栈仅能在线性表的一端进行操作 栈顶(Top):允许操作的一端 栈底(Bottom):不允许操作的一端 Stack的常用操作 创建栈 销毁栈 清空栈 进栈 出栈 获取栈顶元素 ...

  3. linux内核系统调用和标准C库函数的关系分析

    http://blog.csdn.net/skyflying2012/article/details/10044343

  4. TCP/IP协议原理与应用笔记04:子网掩码

    1. 子网掩码 是IP 参照物:分网段用的! 比如 192.168.0.1 和192.168.0.2(1).子网掩码为 255.255.255.0那么192.168.0.X 在同一个网段,能互相访问. ...

  5. ambassador docker container linking

    http://docs.docker.com/articles/ambassador_pattern_linking/

  6. jvm内存模型及分配参数

    jvm内存模型 程序计数器:是一块很小的内存空间.当线程数量超过cpu数量时,线程之间根据时间片轮询抢夺cpu资源.每一个线程都必须用一个独立的程序计数器,用于记录下一条要运行的指令. java虚拟机 ...

  7. 介绍一些适用于 Web 开发者的 Atom 编辑器插件

    Atom 的社区很繁荣,有着丰富的扩展/插件(packages).安装 Atom 的 Package 非常简单,可以在编辑器的偏好设置里面安装,也可以在命令行中使用 apm 命令来安装. 在介绍适用于 ...

  8. [转]在.Net中使用Oracle的表类型和对象类型

    本文转自:http://www.cnblogs.com/studyzy/archive/2010/10/13/1850161.html 在一般的数据存取操作过程中,如果要对一个主表和对应的子表进行插入 ...

  9. [转]在64位的环境中使用VS建立Web项目进行Oracle连接需要注意WebDev是32位的

    本文转自:http://www.cnblogs.com/studyzy/archive/2010/10/28/1863056.html 我们平时使用的都是32位的机器进行开发,装的都是32位的软件,但 ...

  10. 关于工作流之最后Assign给TeamLeader

    如果你的单子Buddy验证通过了.然后也进行了Integrate了,然后就可以把这个单子给TL(Team Leader)了. >>>>>>>>>& ...