从Hibernate检索时,忽略具有换行符的数据库列数据?

时间:2017-11-14 11:40:07

标签: spring html5 spring-4

CLOB数据库列数据包含换行符:

enter image description here

当我检索它并在html表格单元格中显示数据时,将忽略换行符:

    @Override
    @Transactional
    public String getPrevisionRessourceAutreForProduit(Objectif produit) {

        String hql = "select to_char(r.ress_comment_1) " + 
                     "from ressource r join type_ressource t on r.type_ress_code = t.type_ress_code " + 
                     "left join objectif o on r.obj_code = o.obj_code " + 
                     "where o.obj_code = " + produit.getCode().toString() + " and upper(t.type_ress_code) = 'AUT'";

        Session sessionDynamic = Utils.createDynamicSession(env);

        Query query = sessionDynamic.createSQLQuery(hql);

        @SuppressWarnings("unchecked")
        List<String> list = (List<String>) query.list();

        sessionDynamic.close();

        if (list.isEmpty())
            return "";
        else
            return list.get(0) == null ? "" : list.get(0);

    }

enter image description here

那么如何解决呢?

1 个答案:

答案 0 :(得分:0)

我通过将数据包含在标记<pre>...</pre>

中找到了解决方案