JPA # entity attributes converter

__ shocked at the contents turned out to be blank

 

Use (best value between fields and automatic conversion database entity attributes):


 

-

1. POJO persisted to the database table when some special properties after treatment, with the treated field as the value of the database.

2. From the database query dictation recorded and mapped to POJO when, after special treatment for certain fields of POJO assigned to the property.

-


 

 

 

Highlights:


 

-

1. To achieve javax.persistence.AttributeConverter <>, the interface

2. Override public Y convertToDatabaseColumn (X attribute); and a public X convertToEntityAttribute (Y dbData); method.

3. The entity class and then add annotations on relevant attributes @Convert (converter = MyAttributeConverterImpl.class)

-


 

 

 

demo:


 

-

 

-


 

Guess you like

Origin www.cnblogs.com/luohaonan/p/11268139.html
Recommended