How to make a similar display?

For example, there is a class Deposit , and in it a field of type Currency . The Currency class contains an Amount field of type long and a Code field of type String .

There are two columns in the table: money_amount and currency . How could one describe this case with annotations?

 @Column(name = ???) private Currency currency; 

    1 answer 1

     @Embeddable public class Currency { @Column(name = "money_amount") public long amount; @Column(name = "currency") public String code; } @Entity public class Deposit { @Embedded private Currency currency; }