Explanation of @transient, @JsonIgnoreProperties, @JsonIgnore, @JsonFormat, @JsonSerialize and other annotations in Hibernate JPA

Source: Internet
Author: User

1. @Transient

@Transient indicates that the property is not a mapping to a field in a database table, and the ORM framework ignores the property;
If a property is not a field mapping for a database table, it must be marked as @transient, otherwise the ORM framework defaults to its annotation as @basic;

Indicates that the field is not in the database table

@Transient
public int getage () {
return;
}

Jackson Related:

2. @JsonIgnoreProperties

This annotation is a class annotation that, when JSON is serialized, ignores some properties in the Java Bean, and both serialization and deserialization are affected.

3. @JsonIgnore

This annotation is used on properties or methods (preferably on attributes), as in the @jsonignoreproperties above.

4. @JsonFormat

This annotation is used for attributes or methods (preferably on attributes), and it is convenient to convert the date type directly into the pattern we want, such as @jsonformat (pattern = "Yyyy-mm-dd hh-mm-ss")

5. @JsonSerialize

This annotation is used on attributes or Getter methods to embed our custom code when serializing, such as when serializing a double with a two-bit decimal point behind it.

6. @JsonDeserialize

This annotation is used on attributes or setter methods, and can be used to embed our custom code when deserializing, similar to the above @jsonserialize

Explanation of @transient, @JsonIgnoreProperties, @JsonIgnore, @JsonFormat, @JsonSerialize and other annotations in Hibernate JPA

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.