Hibernate / EclipseLink Interview questions
What is the difference between EclipseLink's @Convert and JPA's standard AttributeConverter?
Standard JPA's AttributeConverter interface, paired with @Convert, is the portable, spec-defined way to transform an attribute between its Java type and a basic database column type; any JPA provider recognizes it. EclipseLink additionally ships its own broader family of native converters, which predate and go beyond what the standard interface covers.
| Standard AttributeConverter | EclipseLink native converters |
| Portable across any JPA provider. | EclipseLink-specific; not portable. |
| Converts to/from simple database column types. | Includes richer converters like Serialized, Struct, and TypeConversion for database-specific structured types. |
| Applied via @Convert or autoApply. | Applied via EclipseLink-specific annotations or Customizer configuration. |
For most straightforward type mapping (an enum to a string column, a custom value object to a number), the standard AttributeConverter is sufficient and preferable for portability. EclipseLink's native converters become relevant for scenarios the standard interface wasn't designed for, like mapping to a database-specific structured object type, where reaching for a provider-specific extension is the only practical option anyway.
More Related questions...