String Encoding Issue


Hi all

Encounter a character encoding issue when i try to retrieve a String column containing Chinese character.

Retrieve a String column on odb file. 

em = emf.createEntityManager();
Query query = em.createQuery("SELECT fu FROM FarmUnit fu");

But, when try to print the value out as:

List<FarmUnit> result = db.getFarmUnits();
    for (Iterator<FarmUnit> itr = result.iterator(); itr.hasNext();) {
    System.out.println(; // name is a string column


å?‹å–„å°?è¾²å?Šå?‹å¥½å» 商
é˜¿æ–‡åˆ†äº«è¾²å ´            
梅å·žè¾²å ´
åŠ ç•™æ²™åŸ”è¾²å ´
ç‡•éŠ˜è¾²å ´
æº?ç¦¾ç¶ è¾²å ´
è¿´å–„æœ‰æ©Ÿè¾²å ´
æ²›èŠ³è¾²å ´

wondering that is there anyway to change the charset of the column? or did i miss anything else?


ObjectDB does not modify strings - when you retrieve a string from an ObjectDB database you should get exactly the same String object that you have stored. Therefore, it is very likely that if you try to print the String field when you persist your entity object you will get the same result as printing the String values that the query returns. 

If you can show using a simple test case that a retrieved string is different than the string that was stored (e.g. by comparing them using equals) then this will require a fix of ObjectDB. Otherwise, this issue is probably not related to ObjectDB and the problem is actually with the strings that are stored not just the strings that are retrieved.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login