Skip to main content

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

Hi Andreas,

I'm afraid I don't know Scala. Can you give a description of what you are hoping for.

We don't have converters on xToOne relationships, but I am trying to figure out if there is something we can do in our event framework to deal with the issue.

-Tom

On 30/05/2013 10:16 AM, Andreas Joseph Krogh wrote:
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


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



Back to the top