Hello,
I have an Oracle 9.2 dabatase and a CLOB field containing special characters, for example in the word "Zürich". I checked directly on the database and I could see it perfectly being displayed there, but after doing a search using Hibernate the special character is being displayed as question mark, as "Z?rich".
This is the way I am getting the value:
public static AuditAttachment getAttachment(long id) { AuditAttachment result = null; Session session = null; try { session = getSessionFactory().openSession(); // use with JTA session context class result = (AuditAttachment)session.get(AuditAttachment.class, id); result.setAttachmentType("text/xml; charset=UTF-8"); } catch (HibernateException he) { throw he; } finally { if (session != null) session.close(); } return result; }
And this is the way I am calling the previous function:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { response.setContentType("text/xml; charset=UTF-8"); long attachmentId = Long.parseLong(request.getParameter("id")); AuditAttachment aa = AuditDataHelper.getAttachment(attachmentId); response.setHeader("Pragma", "no-cache"); PrintWriter pw = new PrintWriter(response.getOutputStream(),true); String clob = aa.getAttachmentBody().getSubString(1, (int)aa.getAttachmentBody().length()); pw.print(clob); pw.close(); }
Somehow the string clob is containing "?" instead of "ü".
Does anyone have a hint about it?
Thanks!
|