spring data mongodb中,如果对象中的属性不想加入到数据库字段中
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中,如果对象中的属性不想加入到数据库字段中的更多相关文章
- 如何在Spring Data MongoDB 中保存和查询动态字段
原文: https://stackoverflow.com/questions/46466562/how-to-save-and-query-dynamic-fields-in-spring-data ...
- Spring Data JPA系列2:SpringBoot集成JPA详细教程,快速在项目中熟练使用JPA
大家好,又见面了. 这是Spring Data JPA系列的第2篇,在上一篇<Spring Data JPA系列1:JDBC.ORM.JPA.Spring Data JPA,傻傻分不清楚?给你个 ...
- Spring Data MongoDB 五:进阶文档查询(分页、Morphia)(二)
Spring Data MongoDB 三:基本文档查询(Query.BasicQuery)(一) 学习MongoDB 六: MongoDB查询(游标操作.游标信息)(三) 一.简单介绍 Spring ...
- spring data mongodb 配置遇到的几个问题
一. mongodb 2.2版本以上的配置 spring.data.mongodb.uri = mongodb://newlook:newlook@192.168.0.109:27017/admin ...
- 使用Spring访问Mongodb的方法大全——Spring Data MongoDB查询指南
1.概述 Spring Data MongoDB 是Spring框架访问mongodb的神器,借助它可以非常方便的读写mongo库.本文介绍使用Spring Data MongoDB来访问mongod ...
- Spring data mongodb @CreatedBy@LastModifiedBy@CreatedBy@LastModifiedBy SpringSecurityAuditorAware,只记录用户名
要在Spring data mongodb 中使用@CreatedBy@LastModifiedBy@CreatedBy@LastModifiedBy 这四个注解 必须实现 SpringSecuri ...
- Spring Data MongoDB 三:基本文档查询(Query、BasicQuery)(一)
一.简单介绍 Spring Data MongoDB提供了org.springframework.data.mongodb.core.MongoTemplate对MongoDB的CRUD的操作,上一 ...
- Spring Data MongoDB 一:入门篇(环境搭建、简单的CRUD操作)
一.简介 Spring Data MongoDB 项目提供与MongoDB文档数据库的集成.Spring Data MongoDB POJO的关键功能区域为中心的模型与MongoDB的DBColle ...
- Spring Data MongoDB 三:基本文档查询(Query、BasicQuery
一.简介 spring Data MongoDB提供了org.springframework.data.mongodb.core.MongoTemplate对MongoDB的CRUD的操作,上一篇我 ...
随机推荐
- VMWare9下基于Ubuntu12.10搭建Hadoop-1.2.1集群
VMWare9下基于Ubuntu12.10搭建Hadoop-1.2.1集群 下一篇:VMWare9下基于Ubuntu12.10搭建Hadoop-1.2.1集群-整合Zookeeper和Hbase 近期 ...
- Floating-Info---Android
https://github.com/alt236/Floating-Info---Android
- iOS UIView 基本属性用法
.创建UIView UIView * redView = [[UIView alloc] initWithFrame:CGRectMake(, , , )]; UIView * blueView = ...
- iOS开发——网络编程OC篇&Socket编程
Socket编程 一.网络各个协议:TCP/IP.SOCKET.HTTP等 网络七层由下往上分别为物理层.数据链路层.网络层.传输层.会话层.表示层和应用层. 其中物理层.数据链路层和网络层通常被称作 ...
- Mysql字符集设置 2 图
基本概念 • 字符(Character)是指人类语言中最小的表义符号.例如'A'.'B'等: • 给定一系列字符,对每个字符赋予一个数值,用数值来代表对应的字符,这一数值就是字符的编码(Encodin ...
- 一个.Net程序员:既然选择了编程,只管风雨兼程(转)
一个.Net程序员:既然选择了编程,只管风雨兼程 一次会议记录是不会有人感兴趣的,做标题党也是不道德的.所以,走了个折衷的路线,标题不叫会议记录, 内容不纯总结,技术加吐槽,经验加总结. 对于一个程序 ...
- android开发之路01
一.android系统被分为4个层次:1.最下层的是linux核心,包括多个驱动程序,提供了操作系统应该具备的核心功能:2.在linux核心之上,包括两个部分,一部分是Android Runtime( ...
- ssh用root直接登录失败的问题
解决方法: 1) 以root身份,chmod +w /etc/ssh/sshd_config 2) vi /etc/ssh/sshd_config 3) 将PermitRootLogin no改成Pe ...
- [Oracle EBS R12]SQL Queries and Multi-Org Architecture in Release 12 (Doc ID 462383.1)
In this Document Abstract History Details Previous Releases Release 12 Multi-Org Session ...
- (转)sql 时间转换格式 convert(varchar(10),字段名,转换格式)
convert(varchar(10),字段名,转换格式) CONVERT(nvarchar(10),count_time,121) CONVERT为日期转换函数,一般就是在时间类型(datetime ...