I have two tables:
1) Application(int appid, int statusid, String appname, String appcity with getter and Setter methods)
2) App_Status(int statusid,String statusDescription with setter and getter methods)
I want to map Application table with App_Status so that I don’t have to query separately App_Status table in order to get the statusDescription. One thing I have to careful is that no matter what (Insert,update or delete) to the Application table the App_Status table should be unaffected means its a read only table which is maintained by the DBA internally and used only for lookup table.
I am using JPA annotations so please suggest how to handle this.
The following should work. Map an
AppStatusentity on theApp_Statustable:And declare it with a one-to-one association in the
Applicationentity:Pay a special attention to the following details:
EAGER(note that EAGER is the default if you don’t define it) so that theAppStatuswill be eagerly fetched when loading anApplication.ApplicationtoAppStatus.to retrieve all
Application, use a FETCH JOIN