Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Example AttributeTransformer for @Transformation
Example AttributeTransformer for @Transformation [message #1076485] Wed, 31 July 2013 13:15 Go to next message
Phill Ashworth is currently offline Phill AshworthFriend
Messages: 5
Registered: August 2012
Junior Member
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 15:14 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Did you try mapping it using an @Embedded relationship instead? You can use an orm.xml to be Money as an Embeddable.


James : Wiki : Book : Blog : Twitter
Previous Topic:Cache Annotation
Next Topic:MOXy unmarshalling of nulls
Goto Forum:
  


Current Time: Fri Apr 26 06:56:35 GMT 2024

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

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

Back to the top