Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Converters for non-basic types

Hi.
 
Is it possible to have converters for @{Many,One}ToOne relations?
 
I have a project in Scala and use Option whereever I can on basic-types, having appropriate converters for Option[DateTime], Option[Int] etc. but would like to use Option instead of null for relations.
 
I know I can get around it by having getters/setters wrapping the private mappings and use field-based mappings but accessors for manipulation, like this:
 
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "project_id")
private[this] var project: Project = null
def projectOpt = Option(project)
def projectOpt_=(newVal:Option[Project]) {project = newVal.orNull}
 
But it would be cool if one could write:
 
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "project_id")
@Convert(converter = classOf[ProjectOptionConverter])
var project: Option[Project] = None
 
This is not possible in Hibernate, is it possible in EclipseLink?
 
Thanks.
 
--
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