Hello,
We are developing web application that supports localization including localized objects in database. The idea is to have a map (locale => value) for each property in object that needs multilanguage value.
We prepared this kind of collection-of-elements mapping for an object:
Code:
<property name="nameResourceId" type="int" column="name_resource_id" />
<map name="name" table="resource" cascade="all,delete-orphan" >
<key column="resourceId" property-ref="nameResourceId" />
<map-key type="string" column="locale" />
<element column="value" type="string" />
</map>
This map contains localized property values keyed by a locale.
We use property-ref as there may be more than one localized property in the object, so we can have a few "resource identifiers" in an object (like mentioned above 'nameResourceId') .
It seems to work fine, but we figured out some performance issues:
1. Table 'resource' has no primary key - we would like to use it for fast updates.
2. Hibernate does not generate index for 'resource.resourceId' column, what makes joins inefficient
After some research we have not found a way to
1. suggest Hibernate to generate and use primary key on 'resource' table,
2. suggest Hibernate to generate index on 'resource.resourceId' (well, we can do it by hand, but it would be nice to have this done automaticly)
Is there any way to solve above problems? Maybe some of you has already touched a problem of localization in Hibernate and can provide some hints?
Hibernate version: 3.2.5
Name and version of the database you are using:MySQL 5.0