Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Example AttributeTransformer for @Transformation
Example AttributeTransformer for @Transformation [message #1076485] Wed, 31 July 2013 09:15 Go to next message
Eclipse UserFriend
I'm trying to convert an application from Hibernate and running into difficulties with custom mappings.

I need to persist instances of Joda Money and the currency and amount need to be stored in separate database fields so a simple @Converter will not work.
It seems the only way to do this is with a @Transformation as seen here:
http: //stackoverflow.com/questions/16269002/how-to-query-properties-of-an-entity-attribute-mapped-using-eclipselink-readtr

@Transformation(fetch = FetchType.EAGER, optional = false)
@ReadTransformer(transformerClass = MoneyReadTransformer.class)
@WriteTransformers({
        @WriteTransformer(
                transformerClass = MoneyCurrencyWriteTransformer.class,
                column = @Column(name = "currency", nullable = false)),
        @WriteTransformer(
                transformerClass = MoneyAmountWriteTransformer.class,
                column = @Column(name = "amount", nullable = false))
})
private Money price;


Implementing the FieldTransformer for the @WriteTransformer seems straightforward but I can't find any examples of how to implement AttributeTransformer for reconstructing the entity from the database fields.

Can anyone point me to an example AttributeTransformer implementation, I've spent a fair bit of time researching this but drawn a blank so far.
Re: Example AttributeTransformer for @Transformation [message #1082442 is a reply to message #1076485] Thu, 08 August 2013 11:14 Go to previous message
Eclipse UserFriend
Did you try mapping it using an @Embedded relationship instead? You can use an orm.xml to be Money as an Embeddable.
Previous Topic:Cache Annotation
Next Topic:MOXy unmarshalling of nulls
Goto Forum:
  


Current Time: Thu Jul 03 06:54:54 EDT 2025

Powered by FUDForum. Page generated in 0.03240 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top