These are my tables:
Product:
ID PRICE NAME DESCRIPTION
1 100 laptop laptop_desc
2 200 mouse mouse_desc
Product_Translations:
PID LANG NAME DESCRIPTION
1 ch 伊吾 伊吾伊吾
Please don't worry about name and description in the Product table. We are keeping it to avoid join if default language is selected by the user.
Now I need to write a query to get all the products from Product according to the users's language with fallback that if no translations for name and description are found in Product_Translations get them from Product table. I tried couple of different ways, but couldn't make it work. Update:
I require all the columns from Product table(In this example, I only gave 2, but my actual table has more columns). And one more restriction is that I need to generate this query using JPA Criteria API, so any SQL keywords not supported by JPA may not work for me.
Thanks for your help.