Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename the field name in Spring-mongodb when data insert?

I using spring mongodb to my project.When I insert the data of this class:

public class Person {

    @Id
    private String personId;

    private String name;
    private int age;
    private List<String> friends;
    private Date tempValue;
}

It insert to mongodb:

{
  "_id" : ObjectId("543de17f2e631eb39036e60a"),
  "name" : "Johnathan",
  "age" : 73,
  "friends" : ["hh", "hhhh", "hoho"],
  "tempValue" : ISODate("2014-10-15T02:52:47.721Z")
}

I want to change the field name of "tempIntergeValue" to "temp_value",it will be more like database name rule.

like image 543
v11 Avatar asked Oct 15 '14 02:10

v11


1 Answers

Simply annotate your field with @Field as follows:

@Field("temp_value")
private Date tempValue;
like image 156
arun Avatar answered Sep 23 '22 01:09

arun