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. 安卓服务(Service)的两种开启方式以及服务的生命周期

    安卓中服务的开启方式 一:採用start的方式开启服务 调用函数:startService(Intent)->onCreate()->onStart()/onStartCommand()- ...

  2. iOS开发——新特性OC篇&Objective新特性

    Objective新特性 Overview 自 WWDC 2015 推出和开源 Swift 2.0 后,大家对 Swift 的热情又一次高涨起来,在羡慕创业公司的朋友们大谈 Swift 新特性的同时, ...

  3. Android开发心得(转)

    前言: 很早以前,就听人说过android以后会火起来,作为一个前瞻性对它有所了解会是一个转型的好机会,javaweb太成熟饱和了,现在市面上各种android手机层出不穷,网上各种android视频 ...

  4. Web应用Word生成

    前段时间接到一个Web应用自己主动生成Word的需求,现整理了下一些关键步骤拿来分享一下. 思路:(注:这里仅仅针对WORD2003版本号.其他版本号大同小异.) 由于WORD文件内部的数据及格式等是 ...

  5. 利用DBExportDoc V1.0 For MySQL自动生成数据库表结构文档

    对于DBA或开发来说,如何规范化你的数据库表结构文档是灰常之重要的一件事情.但是当你的库,你的表排山倒海滴多的时候,你就会很头疼了. 推荐一款工具DBExportDoc V1.0 For MySQL( ...

  6. svn :Can't connect to host *.*.*.*': 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。

    Can't connect to host *.*.*.*': 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败. -------------------------------- ...

  7. windows 7 共享,未授予用户在此计算机上的请求登录类型

    刚刚重装了windows7,新下载的一个ghost版本,结果却不能共享,每次访问这台机器的共享都提示, 未授予用户在此计算机上的请求登录类型 这个情况好像是存在于win7访问win7,我用一台XP系统 ...

  8. oracle数据库中,分天查询数目

    select to_CHAR(SP_MT_TIME,'DD'),count(*) from table2 group by to_CHAR(SP_MT_TIME,'DD');

  9. ios通知-kvo

    // KVC: Key Value Coding, 常见作用:给模型属性赋值    // KVO: Key Value Observing, 常用作用:监听模型属性值的改变 // // ViewCon ...

  10. 学习opencv中文版教程——第二章

    学习opencv中文版教程——第二章 所有案例,跑起来~~~然而并没有都跑起来...我只把我能跑的都尽量跑了,毕竟看书还是很生硬,能运行能出结果,才比较好. 越着急,心越慌,越是着急,越要慢,越是陌生 ...