I’m using Play-Morphia to create my application, and I have a class which has a public static final members, and when I use the find() function on my object, I get the object but only with its public or private members, but not its public static final members.
for example:
public class Person{
public String name;
public int age;
public static final String id;
}
Now, after saving this object to Mongo and then calling Person.find().first() or any Person.find() functions, I get: {“name” : “John”, “age” : 30} –> with no ID included.
Does anyone has a solution to this problem?
static variables are at class level, while mongodb entities are corresponding to each object. Therefore static variables will not be saved into mongodb collection. Can you let us know why you want to put a static (and even final) variable into mongodb? What’s your business logic?