title: Using UUID with EclipseLink and PostgreSQL
body: <p>I want to use the PostgreSQL uuid type for objects' primary keys.
  For that I've created a converter (implementing the Converter interface).
  Bellow is the relevant code:  </p>
  
  <pre><code>    @Override
      public void initialize(DatabaseMapping mapping, Session session) {
          final DatabaseField field;
          if (mapping instanceof DirectCollectionMapping) {
              field = ((DirectCollectionMapping) mapping).getDirectField();
          } else {
              field = mapping.getField();
          }
  
          field.setSqlType(Types.OTHER);
          field.setTypeName("uuid");
          field.setColumnDefinition("UUID");
      }
  </code></pre>
  
  <p>Then I've annotated the relevant entity X with the bellow annotations:  </p>
  
  <pre><code>@Converter(name="uuidConverter",converterCalss=UUIDConverter.class)
  @Convert("uuidConverter")
  @Id
  public UUID getId()
  {
      return id;
  }
  </code></pre>
  
  <p>The problem is that I have another class (Y) which has the following definition:</p>
  
  <pre><code>@ManyToOne(targetEntity = X.class)
  @JoinColumn(name = "x_id")
  public X getX();
  </code></pre>
  
  <p>Although EclipseLink created the tables as expected it sends a string to the database when trying to insert objects of type Y.
  Postgres returns the following error message:</p>
  
  <pre><code>column "id" is of type uuid but expression is of type character varying at character
  </code></pre>
  
  <p>Any solutions / work around will be appreciated.</p>