[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Mapping composite/complex types (hibernate UserType alternative)
|
In JPA you can use an Embedded mapping for this.
In EclipseLink you could also map this using a TransformationMapping.
See,
http://www.eclipse.org/eclipselink/api/1.1.2/org/eclipse/persistence/annotations/Transformation.html
jobr wrote:
>
> Hi,
>
> We are in the middle of researching a migration from hibernate to
> eclipselink.
> However there is one thing I cannot find a good alternative for :
> hibernate UserTypes, these can be used to define your own db mappings
> for complex/composite types, eg a Money attribute. example code :
>
> @Entity
> public class Account {
>
> @Id
> private String accountId;
> ...
> @??
> private Money balance;
> }
>
>
> public class Money {
>
> private BigDecimal amount;
> private String currency;
>
> public Money(BigDecimal amount, String currency) {
> ...
> }
>
> }
>
> ACCOUNT table on database :
>
> accountId VARCHAR2(20)
> balamount NUMBER
> balcurrency VARCHAR(3)
> ...
>
> Is it possible with eclipselink to define a mapping on the balance
> attribute so that is maps the Money object on two different fields in
> the database (balamount & balcurrency) within the account table? (so
> we don't want a separate money table)
> I 've read about converters but this seems to be limited to a one on
> one mapping, i.e. you can only map the 'balance' attribute in the
> account entity on one single column in the related table.
> Am I correct here? is this not at all possible with Eclipselink? this
> would be a real showstopper for us.
>
> cheers, Joost
>
>
-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/Mapping-composite-complex-types-%28hibernate-UserType-alternative%29-tp25315701p25385353.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.