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. Mac Pro更换SSD后,在Win7下启用ACHI的方法AHCI

    在Mac Pro下更换SSD后,如果安装Win7,要将SSD改为AHCI模式是非常麻烦的.本文介绍如何将Mac的Win7下的SSD改为AHCI方式驱动,及几种常见问题的处理. 一.当Lion与Win7 ...

  2. Linux中的文件描述符与打开文件之间的关系------------每天进步一点点系列

    http://blog.csdn.net/cywosp/article/details/38965239 1. 概述     在Linux系统中一切皆可以看成是文件,文件又可分为:普通文件.目录文件. ...

  3. Number of failed login attempts exceeds threshold value

    OEM发出好多告警,Number of failed login attempts exceeds threshold value. profile当前配置10次失败就会锁定user 查看下,dba_ ...

  4. jquery中的index方法

    问题描述:灵活使用jquery中的index方法 方法签名:index([selector|element]) 用法概述:P1.index(P2)  //调用者P1可以为对象或集合 参数为空,返回P1 ...

  5. 关于Struts2中的值栈与OGNL表达式

    1.1.1    OGNL概述: Object Graphic Navigation Language(对象图导航语言)的缩写 * EL     :OGNL比EL功能强大很多倍. 它是一个开源项目. ...

  6. 301页面转向 php

    新建301.php页面,在程序入口文件index.php引用301.php页面 301.php内容如下,仅用于参考: <?php$the_host = $_SERVER['HTTP_HOST'] ...

  7. angularjs的一些优化小技巧

    尽可能少调用 ng-repeat ng-repeat默认会创建很多监听器,所以在数据量很大的时候,这个非常消耗页面性能,我觉的只有在当需要经常更新数据列表的时候才需要用ng-repeat,要不然放那么 ...

  8. 第一个Servlet

    一,第一个Servlet的编写过程 1,建立JavaWeb应用目录 HelloServlet--web应用名称 classes:Servlet就放在此处 lib web.xml 2,classes目录 ...

  9. oracle添加表字段跟修改表字段属性

    添加字段 alter table mid_contactinfo add(status varchar(20),createdate varchar(50),modifydate varchar(50 ...

  10. 【高级JSE技术】线程池

    引言 线程池是java并发技术中常用的一种,通过缓存线程资源避免了频繁的创建销毁线程带来的额外开销,从而提高性能.JDK中有相应的Executor框架实现,而Spring中也带有线程池的功能.本文将从 ...