Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localization tables in class/object view

The core application I am working on needs to support a bilingual webapplication in near future.

Few of the transaction table and all of the static table has localization data.

I am lost at representing this data at object model.Should the localization table be represented as a Map or List of localization objects in the main object ?

Below is the Data Model,

DEAL table
------------------------------------------------------------------------
DEAL_ID | DEAL_NAME | DEAL_OWNER | CREATED_DATE | CREATED_BY | DEAL_TYPE 
1          test        test         29-10-2105     user         1
2          test        test         29-10-2105     user         2
3          test        test         29-10-2105     user         2
4          test        test         29-10-2105     user         1

DEAL_LOCALIZATION table
------------------------------------------------------------------------
DEAL_ID | LANGUAGE_CODE | DEAL_NAME | DEAL_DESC 
1              en          test1      test name
1              jp          テスト1     test name
2              en          test2      test name
2              jp          テスト2     test name


DEAL_TYPE table
-------------------------------------------------------------------------
ID
1
2

DEAL_TYPE_LOCALIZATION table
-------------------------------------------------------------------------
ID | LANGUAGE_CODE | TYPE_NAME
1          en         dealtype1
2          en         dealtype2
1          jp         ビジネスケース1
2          jp         ビジネスケース2

Should the Deal object has a list of DealType,DealLocalization object or Deal object should have a map of Dealtype,DealLocalization objects with a LocalKey (id,LanguageCode) object as key.

Thanks in advance for suggestions.

like image 807
Krithika Vittal Avatar asked Jun 08 '17 20:06

Krithika Vittal


1 Answers

In Hibernate,

@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "DEAL_ID")
public Deal getDeal() {
    return deal;
}

in the Deal_Localization class would probably be enough. Do you really need anything more?

like image 83
mikep Avatar answered Oct 04 '22 15:10

mikep