I have a working Java EE application that is hosted on JBoss. It uses EclipseLink to manage data in a Postgres database. I am now moving the entity classes to a separate jar so that they can be shared by other components. After doing this, Postgres is giving the following error:
ERROR: operator does not exist: uuid = bytea at character 209
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
It looks like my converter class is not being called. Here is what my converter class looks like:
package model.util;
import org.eclipse.persistence.mappings.DatabaseMapping;
import org.eclipse.persistence.mappings.converters.Converter;
import org.eclipse.persistence.sessions.Session;
import java.sql.Types;
import java.util.UUID;
public class PgUuidConverter
implements Converter
{
@Override
public boolean isMutable ()
{
return false;
}
@Override
public Object convertDataValueToObjectValue (Object value, Session session)
{
return (UUID) value;
}
@Override
public Object convertObjectValueToDataValue (Object value, Session session)
{
return (UUID) value;
}
@Override
public void initialize (DatabaseMapping mapping, Session session)
{
mapping.getField ().setSqlType (Types.OTHER);
}
}
And here is how I'm using it in my entities:
package model;
import model.util.PgUuidConverter;
import org.eclipse.persistence.annotations.Convert;
import org.eclipse.persistence.annotations.Converter;
import java.util.UUID;
import javax.persistence.*;
@Entity
@Table (
name = "item",
schema = "main"
)
@Converter (
name = "uuid",
converterClass = PgUuidConverter.class
)
public class Item
{
public Item () {}
@Id
@Column (
name = "item_id",
unique = true,
nullable = false
)
private UUID itemId;
@Column (name = "layer_id")
@Convert ("uuid")
private UUID layerId;
public UUID getItemId ()
{
return this.itemId;
}
public UUID getLayerId ()
{
return this.layerId;
}
public void setItemId (UUID itemId)
{
this.itemId = itemId;
}
public void setLayerId (UUID layerId)
{
this.layerId = layerId;
}
}
Is there some kind of configuration that I'm missing?