0

I have a situation like , I need to save some receipt details in a table and along with that receipt file will also be there. SO I decided to keep 2 table one for receipt_details and other for receipt_file

class ReceiptDetails{

@Id
int id;

BigDecimal amount;

//Otherstuff
}

Here i have to include receiptFile details such as content, filename etc from second table as well.

Should I use @OnetoOne or @SecondaryTable in this scenario. In what situation each annotation fits?

Vipin CP
  • 3,642
  • 3
  • 33
  • 55
  • Maybe this will help you: https://stackoverflow.com/questions/3512721/secondarytables-or-onetoone-associations – Hannes Aug 15 '19 at 10:00
  • @Hannes It only says if you want seperate entity for second table then only use OnetoOne. I will use fetch eager in one to one and not required it as a seperate entity. But is that justification enough to use secondary table? or any other hidden features? – Vipin CP Aug 15 '19 at 10:03
  • If you're targeting the combination for `value=TYPE`, then you'd go for `@SecondaryTable`. if its just for target `value=METHOD,FIELD` go for `@OneToOne`. – Procrastinator Aug 15 '19 at 10:17
  • @procrastinator I didnt understand that targeting the combination? If you don't mind, could you please brief little bit. – Vipin CP Aug 15 '19 at 11:00

0 Answers0