Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Moving Eclipselink Entities to separate jar
Moving Eclipselink Entities to separate jar [message #1716055] Mon, 30 November 2015 21:48 Go to next message
Daryl Foster is currently offline Daryl FosterFriend
Messages: 5
Registered: March 2014
Junior Member
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?
Re: Moving Eclipselink Entities to separate jar [message #1716246 is a reply to message #1716055] Wed, 02 December 2015 13:13 Go to previous message
Daryl Foster is currently offline Daryl FosterFriend
Messages: 5
Registered: March 2014
Junior Member
It looks like the problem is one that appears obvious now. I need to apply the Convert annotation to all UUID fields.

Previously I had only applied the Convert annotation to nullable UUID fields since Postgres was only giving me type errors when UUID fields were set to NULL. Now Postgres is throwing exceptions for all of the UUID fields that don't have Convert annotations.
Previous Topic:Unable to unwrap connection with eclipselink.jdbc.exclusive-connection.mode=Always
Next Topic:Query TimeOut Hints not working in Eclipse Link 2.6
Goto Forum:
  


Current Time: Wed Apr 24 18:40:35 GMT 2024

Powered by FUDForum. Page generated in 0.02857 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top