[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] Using @Converter with parameterized type fails
|
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