欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

spring集成MongoDB 字段大小写映射问题 springmongodb 

程序员文章站 2024-03-15 13:28:05
...
问题:当类属性的字段和mongoDB 的字段不一样或者大小写不一样可以用@Field("XXX") 映射给属性
例子:
package com.kedalo.forecast.bean;

import java.util.Date;
import java.util.List;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Document(collection = "api-constantly")
public class ConstantlyModel {
	
	@Id
	private String id;
	
	private String sid;
	
	private Date st;
	
	private String sname;
	
	private List<Float> lngAndlat;
	
	private String rh;
	
	private String pr1;
	
	private String wd;
	
	private String ws;
	@Field("T")
	private String t;
	@Field("P")
	private String p;
	
	private List<Double> wu =null;//风向
	private List<Double> wv =null;//风速
	private List<Double> pr =null;//降雨
	private List<Double> tm =null;//温度
	private List<Double> tmax =null;//最大温度
	private List<Double> tmin =null;//最小温度
	private List<Double> cloud =null;//最小温度

	
	
	public String getT() {
		return t;
	}

	public void setT(String t) {
		this.t = t;
	}

	public String getP() {
		return p;
	}

	public void setP(String p) {
		this.p = p;
	}

	public List<Double> getWu() {
		return wu;
	}

	public void setWu(List<Double> wu) {
		this.wu = wu;
	}

	public List<Double> getWv() {
		return wv;
	}

	public void setWv(List<Double> wv) {
		this.wv = wv;
	}

	public List<Double> getPr() {
		return pr;
	}

	public void setPr(List<Double> pr) {
		this.pr = pr;
	}

	public List<Double> getTm() {
		return tm;
	}

	public void setTm(List<Double> tm) {
		this.tm = tm;
	}

	public List<Double> getTmax() {
		return tmax;
	}

	public void setTmax(List<Double> tmax) {
		this.tmax = tmax;
	}

	public List<Double> getTmin() {
		return tmin;
	}

	public void setTmin(List<Double> tmin) {
		this.tmin = tmin;
	}

	public List<Double> getCloud() {
		return cloud;
	}

	public void setCloud(List<Double> cloud) {
		this.cloud = cloud;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getSid() {
		return sid;
	}

	public void setSid(String sid) {
		this.sid = sid;
	}

	public Date getSt() {
		return st;
	}

	public void setSt(Date st) {
		this.st = st;
	}

	public String getSname() {
		return sname;
	}

	public void setSname(String sname) {
		this.sname = sname;
	}

	public List<Float> getLngAndlat() {
		return lngAndlat;
	}

	public void setLngAndlat(List<Float> lngAndlat) {
		this.lngAndlat = lngAndlat;
	}

	public String getRh() {
		return rh;
	}

	public void setRh(String rh) {
		this.rh = rh;
	}

	public String getPr1() {
		return pr1;
	}

	public void setPr1(String pr1) {
		this.pr1 = pr1;
	}

	public String getWd() {
		return wd;
	}

	public void setWd(String wd) {
		this.wd = wd;
	}

	public String getWs() {
		return ws;
	}

	public void setWs(String ws) {
		this.ws = ws;
	}
	
	
	
	

}

相关标签: spring mongodb