JPA Attribute Converter: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 17: Line 17:


=Programming Model=
=Programming Model=
==@Convert Annotation==


<syntaxhighlight lang='java'>
<syntaxhighlight lang='java'>
@Convert(converter = PayloadConverter.class)
@Convert(converter = PayloadConverter.class)
private String payload;
private String payload;
</syntaxhighlight>
==The Converter Class==
<syntaxhighlight lang='java'>
</syntaxhighlight>
</syntaxhighlight>

Revision as of 20:10, 31 October 2018

External

Internal

Overview

An attribute converter allows the developer to specify methods to convert between the database and the Java representation of an attribute.

Playground Example

https://github.com/ovidiuf/playground/tree/master/spring/jpa/attribute-converter

Programming Model

@Convert Annotation

@Convert(converter = PayloadConverter.class)
private String payload;

The Converter Class