Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Postgresql and UUID eclipselink 2.4.0

Hi Edward,

I think you need to either:

1.) provide a custom converter (UUID (java) <-> UUID (PostgreSQL))

2.) provide an custom type mapping


...for 1.) there are enough information out there on the EclipseLink wiki, for 2.) there is almost no information how to code that, as I still have the same problem with other types.

Cheers,

	Ancoron


On 08/06/2012 07:11 PM, Edward Mann wrote:
I have been trying to figure out how to get the native uuid type in
         postgresql and eclipselink to work together. I have a simple
table for
         testing:

         CREATE TABLE elink
         (
           el_id uuid NOT NULL DEFAULT uuid_generate_v4(), -- elink id
           el_name character varying(255), -- elink name
           CONSTRAINT el_pkey PRIMARY KEY (el_id )
           DEFERRABLE INITIALLY IMMEDIATE
         )
         WITH (
           OIDS=FALSE
         );
         ALTER TABLE elink
         OWNER TO emann;
         COMMENT ON COLUMN elink.el_id IS 'elink id';
         COMMENT ON COLUMN elink.el_name IS 'elink name';


         And the annotation on the field for id is:

         @Id
                 @Column(name="el_id")
                 @UuidGenerator(name="uuid")
                 @GeneratedValue(generator="uuid")
                 private UUID elId;

         I have also tried the custom UUIDSequence mentioned on the
website,
         however that did not work either. I get the following error
(this is the
         UUIDSequence native to 2.4.0):

         Exception [EclipseLink-3002] (Eclipse Persistence Services -
         2.4.0.v20120608-r11652):
         org.eclipse.persistence.exceptions.ConversionException
         Exception Description: The object
         [66FB2FFB-2735-4A8C-AFDE-19246C78CC16], of class [class
         java.lang.String], from mapping

[org.eclipse.persistence.mappings.DirectToFieldMapping[elId-->ELINK.el_id]] with descriptor [RelationalDescriptor(model.Elink --> [DatabaseTable(ELINK)])], could not be converted to [class [B].


         So i am really curious about what is the proper way to get this
to work
         using uuid type in postgresql.
         Any help is welcome, thanks in advance.

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users




Back to the top