java - How can I save UTF-8 strings in an ObjectDB JPA database? -


i'm trying save utf-8 strings in objectdb database following code:

resourcebundle entries = utf8classloader.getbundle("localization/language", "fa-ir"); // fa-ir utf-8 , rtl language enumeration<string> keys = entries.getkeys(); (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 , 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 , setters omitted     } } 

localization/language_fa_ir.properties exists , opens properly.

the dao's persistorupdate method nothing more entitymanager.persist function within transaction. (and entitymanager.merge if key exists)

but when open objectdbviewer, see this: screenshot

how can save strings without changing characters?

there no problem objectdb actually, resourcebundle returning not-utf string. solved line:

entity.setvalue(new string(entries.getstring(key).getbytes("iso-8859-1"), "utf-8"));


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -