Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] EL pick wrong converter for parameterized type

På søndag 18. august 2013 kl. 17:57:00, skrev Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>:
Hi.
 
I'm experiencing that EL pick the wrong converter. I have a Scala-project where I have converters for Option[Int] and Option[Long] etc. For some reason the OptionIntegerConverter is used where OptionLongConverter should be used.
 
I'm unable to reproduce this on another project.
 
Where in the code is the converters mapped to types, so I can debug and see what's going on?
 
After som digging and debugging here's what's going on:
 
I have a Scala-project and am trying to auto-apply converters for Option[<primitive type>], ie. Option[Long], Option[Int] etc. It appears Scala generates byte-code like Option[java.lang.Object] for these type, as opposed to reference-types (AnyRef) where it correctly generates Option[java.lang.Long]. Because of this it is impossible (I think) for EL to automatically distinguish between fields of type Option[Int] and Option[Long], and the generation of MetadataProject.m_autoApplyConvertAccessors merges all of them to one type, Option[java.lang.Object].
 
The solution is to always annotate fields of Option-primitive types explicitly with @Convert.
 
--
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
 

Back to the top