Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Mapping composite/complex types (hibernate UserType alternative)

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



Back to the top