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?
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
--

Guy Pelletier
ORACLE Canada,
45 O'Connor Street
Suite 400
Ottawa, Ontario
Canada K1P 1A4
Oracle is committed to developing practices
and products that help protect the environment