Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Using @Converter with parameterized type fails

This seems like a bug and the parametrized type should work.

Can you enter a bug with this example?

As a work around in the mean time, you'll have to be explicit with the @Convert per attribute as you have done.

Thanks,
Guy

On 04/07/2013 11:26 AM, Andreas Joseph Krogh wrote:
Hi.
 
I'm trying to use converters for a basic-type which is a parameterized type. I have borrowed Functional Java's Option and made it Serializable (for it to be mappeable to a JPA-field) and have them mapped to two different fields like this:
 
@Column(name = "color")
CustomOption<String> color = CustomOption.none();

@Column(name = "milage")
CustomOption<Long> milage = CustomOption.none();
 
Then I have two converters:
 
@Converter(autoApply = true)
public class OptionalLongConverter implements AttributeConverter<CustomOption<Long>, Long> {
@Converter(autoApply = true)
public class OptionalStringConverter implements AttributeConverter<CustomOption<String>, String> {
But EL fails to map them correctly and generates a column of type BIGINT for both:
[EL Fine]: sql: 2013-07-04 17:12:40.507--ServerSession(2079734280)--Connection(550612079)--Thread(Thread[main,5,main])--CREATE TABLE car (id BIGINT NOT NULL, color BIGINT, created TIMESTAMP NOT NULL, milage BIGINT, model VARCHAR(255) NOT NULL, owner_name VARCHAR(255), data_id BIGINT, PRIMARY KEY (id))
 
 
If I map the attributes explicitly:
@Column(name = "color")
@Convert(converter = OptionalStringConverter.class)
CustomOption<String> color = CustomOption.none();

@Column(name = "milage")
@Convert(converter = OptionalLongConverter.class)
CustomOption<Long> milage = CustomOption.none();
It works.
 
 
 
Is this by design or should the auto-convert stuff also work for parameterized types?
 
--
Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc


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

--

Oracle
Guy Pelletier

ORACLE Canada, 45 O'Connor Street Suite 400 Ottawa, Ontario Canada K1P 1A4

Green
            Oracle Oracle is committed to developing practices and products that help protect the environment


Back to the top