Spring Data JPA, how to one attribute map to two columns?

Suppose I have "Account" entity class, and "Transaction" entity class. In table, detail is:


transfer_id, account_from_id, account_to_id, money

565 1 2 12

566 3 1 15

So what annotation or how to code Account entity class, so when I get account.getTransactions, for account_id = 1, it will has 2 transactions? (because both transfer entity involves account id = 1)

@Entity
@Table
public class Account {
     // ...
     
     //TODO: How should I do here? Use which annotation or how to do?
     private Set<Transfer> transfers;
}


Read more here: https://stackoverflow.com/questions/67377829/spring-data-jpa-how-to-one-attribute-map-to-two-columns

Content Attribution

This content was originally published by elisa at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: