I need to create some application and one of its parts is working with localized representation of countries. Let me explain what I mean:
As you know each country has short international name, for example UA is for Ukraine. But users prefer to work with full name of countries. As my application needs to be compatible with many languages (for now it's Ukrainian, Russian, Polish and English) I want to provide mechanism when user asks Country bean for it's name and it returns name using current client locale. In case when there is no available name for current locale it will return default name (for example all default names will be in English).
Now you know the task. I've provided some solution for this problem but I want you to give me advice in one small piece of my solution.
My solution is:
1. I've created entity bean CountryBean that has id, shortName and defaultName fields.
2. I've created entity bean LocalizedCountryDescBean that has cntry_id, locale and name fields. cntry_id and locale is key fields.
3. I've created session bean CountrySessionBean that takes care about all work concerning creating, removing of Countries and so on. Futhermore, this bean provides methods to get localized names of country . It looks up for name field in localized_country_desk where cntry_id and locale corresponds to CountryBean.id and current locale. If there is no appropriate name then it returns defaultName field of CountryBean.
I think that it's not so bad solution but problem is that I must go to DB twice - first time to load CountryBean fields and second time to find appropriate name. It decreases performance to much for me.
And the question, at last.
How could I realize some mechanism to create one data object on server side that consists of all fields I need (id, shortName, defaultName and name) and transfer this object to client.
If somebody knows solution please tell me and it would be preferrable if solution be in XDoclet format.
Best regards. Oleg