@Id 注释是什么?
What does the @Id annotation?
我有一个class有这张便条,@Id
,它有什么用?
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;
}
此注释将字段标记为 Mongo 文档标识符。
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"))
您可以阅读有关 Mongo 文档 ID here 的更多信息。
检查此 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
我有一个class有这张便条,@Id
,它有什么用?
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;
}
此注释将字段标记为 Mongo 文档标识符。
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"))
您可以阅读有关 Mongo 文档 ID here 的更多信息。
检查此 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