java - Id with null value in return with mongoDB -
@mongoobjectid
annotation added insert objectid in database, when data contained in collection return null id. ids , values aren't null.
how id correctly?
my entity
import org.jongo.marshall.jackson.oid.mongoobjectid; import java.io.serializable; import java.util.list; import java.util.map; import java.util.stream.collectors; public class instancia implements serializable { @mongoobjectid string id; string instancia; string categoria; string dono; string data_criacao; string descricao; boolean ativo; map<string, boolean> servicos; public string getid() { return this.id; } public instancia setid(string id) { this.id = id; return this; } public string getinstancia() { return this.instancia; } public instancia setinstancia(string instancia) { this.instancia = instancia; return this; } public string getcategoria() { return this.categoria; } public instancia setcategoria(string categoria) { this.categoria = categoria; return this; } public string getdono() { return this.dono; } public instancia setdono(string dono) { this.dono = dono; return this; } public string getdata_criacao() { return this.data_criacao; } public instancia setdata_criacao(string data_criacao) { this.data_criacao = data_criacao; return this; } public string getdescricao() { return this.descricao; } public instancia setdescricao(string descricao) { this.descricao = descricao; return this; } public boolean getativo() { return this.ativo; } public instancia setativo(boolean ativo) { this.ativo = ativo; return this; } public boolean isservicoenabled(string servico) { boolean b = this.servicos.get(servico); if(b == null){ b = false; } return b; } public list<string> getservicosenabled(){ list<string> servicos = this.servicos.keyset().stream().filter((me) -> { boolean b = this.servicos.get(me); if(b == null){ b = false; } return b; }).collect(collectors.tolist()); return servicos; } }
how trying use oid
instancia instance = new instancia(); instances.find(withoid(instance.id)).as(instancia.class);
Comments
Post a Comment