I'm trying to save some UTF-8 strings in the ObjectDB database with the following code:
ResourceBundle entries = Utf8ClassLoader.getBundle("localization/language", "fa-IR"); // fa-IR is a UTF-8 and RTL language
Enumeration<String> keys = entries.getKeys();
for (String key = keys.nextElement(); keys.hasMoreElements(); key = keys.nextElement()) {
ResourceEntity entity = new ResourceEntity();
entity.setId(new ResourceEntity.PKC(key, locale));
entity.setValue(entries.getObject(key));
resourceDAO.persistOrUpdate(entity);
}
The model:
@Entity
public class ResourceEntity {
@EmbeddedId
private PKC id;
private Object value;
// Getters and setters omitted
@Embeddable
public static class PKC {
String key;
String locale;
public PKC() {}
public PKC(String key, String locale) {
this.key = key;
this.locale = locale;
}
// Getters and setters omitted
}
}
localization/language_fa_IR.properties exists and opens properly.
The DAO's persistOrUpdate method is nothing more than an EntityManager.persist function within a transaction. (and does EntityManager.merge If the key exists)
But when I open the ObjectDBViewer, I see this:
How can I save the strings without changing characters?