Create postgres table mapping with inet type column

I have a table in the postgres database and the column is of type inet, as I do to map this attribute in the entity.

You can use JPA’s @Convert annotation for your entity attribute and write a converter. Please see an example here:

Example of a converter:

public class InetConverter implements AttributeConverter<String, Object> {

  public Object convertToDatabaseColumn(String attribute) {
      if (attribute == null)
          return null;
      PGobject pgobject = new PGobject();
      try {
      } catch (SQLException e) {
          throw new RuntimeException(e);
      return pgobject;

  public String convertToEntityAttribute(Object dbData) {
      return dbData == null ? null : dbData.toString();

Entity attribute annotation:

@Column(name = "IP_ADDRESS")
@Convert(converter = InetConverter.class)
protected String ip_address;

See the full description in the sample project.


Hi ,
Thanks, it worked.