2

I have a class that has this note, @Id, what is the use of it?

package oknok.validacao.resources;

import org.jongo.marshall.jackson.oid.Id;

public class Validacao {

    @Id
    String id;
    String email;
    String instancia;
    String dataCriacao;
    String dataAtualizacao;

}
S. Pauk
  • 5,208
  • 4
  • 31
  • 41
Daniela Morais
  • 2,125
  • 7
  • 28
  • 49

2 Answers2

2

This annotation marks a field as a Mongo document identifier.

unique identifier available on every Mongo document. If it isn't setted, it is generated. To handle it with Jongo, one attribute has to be named _id or annotated with @Id (alias for @JsonProperty("_id"))

quoted from jongo spec

You can read more about Mongo document ID here.

S. Pauk
  • 5,208
  • 4
  • 31
  • 41
-1

Check this link : "Specifies the primary key of an entity. The field or property to which the Id annotation is applied should be one of the following types: any Java primitive type; any primitive wrapper type; String; java.util.Date; java.sql.Date; java.math.BigDecimal; java.math.BigInteger."

https://docs.oracle.com/javaee/6/api/javax/persistence/Id.html

N Kaushik
  • 2,198
  • 18
  • 29