[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2102?page=c...
]
mohammad norouzi commented on HHH-2102:
---------------------------------------
would you please tell me on which version and under the which name or keyword the problem
has been resolved?
problem when design tables to support multi languages
-----------------------------------------------------
Key: HHH-2102
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2102
Project: Hibernate3
Type: Improvement
Environment: Apache Tomcat 5.5, MySql 4.1, Hibernate 3.1
Reporter: mohammad norouzi
Dear Hibernate Team,
We have faced a problem in our enterprise project and we think it could be resolved by
Hibernate. the problem is that our project is supporting many languages, in fact, our
database designed to support this feature. to enagae this feature we have two method to
implementing the tables:
(in order to be clear I am using Employee table as an example)
1. break a table into two tables, one contains locale-independent and the other
locale-dependent informations.
a table, say, "Employee":
Employee (id , birthdate, ssn, employment_type)
and locale-dependent table, say, EmployeeLocale
EmployeeLocale (id, locale_id, given_name, family,....)
2. another way is to seperate locale-dependent information in different tables:
Employee (id , birthdate, ssn, employment_type)
EmployeeEnglish (id, given_name, family,....)
EmployeeFrench (id, given_name, family,....)
EmployeeSpanish (id, given_name, family,....)
....
if information are very huge, maybe the second one has better performance.
any way, the problem comes out when designing the entities and/or value objects with
Hibernate. according to first method, we have a Class Employee and a Class EmployeeLocale
and they have one-to-many relationship with each other. this is not good when you are
working with a big project. in order to access locale-dependent informations you shoud get
the Employee and then get its collection, say, "employeeLocales" and in that
collection there is only one record because you requested it ,for example, with French
locale. in the other hand, when you want to persist some information you should initialize
the collection and then insert an instance of EmployeeLocale class into it.
if you opt the second method, it has some other problem.
first off, you have to create a new entity class for every locale (or every table you
create) and they have the same attributes and fields (data redundancy in designing
entities not tables).
in addition, when insetrting, for example, a new Employee in french, you should use many
"if then else" statements in your codes to check if it is french then
instantiate EmployeeFrench and so on.
however, it will resolved using the design patterns. We are using some workaround to
solve this problem, however, we had to get away some features of Spring framework like
IoC. We have defined an Interface, say, Employee and an Abstract class, say, BaseEmployee
that implements only locale-independent attributes and other classes that extends from
that abstract class and contains locale-dependent info.
and finally, we used the Command Pattern to manage the DAO classes, so, our developers
only know the Employee interface and an manager that returns appropriate DAO to interact
with database, of course, passing an localeId is necessary here.
eventually, I think these are not good and the problem should be manipulated in
Hibernate. I mean we should have only one Entity, say, Employee and it should be populated
with requested locale in a moment, but Hibernate doesnt support these sort of things. I
tried every features of Hibernate, from secondary tables to inheritance, but none of them
work correctly.
As you are developing Hibernate, We wanted to know if you have any idea to get around the
problem or if it will be a new feature in the next versions of hibernate to support this.
any suggestion or comment will be appreciated.
Thank you in advance and wish you success.
Regards
M.Norouzi
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira