If entity.getHistory() is null following code snippet:
(getEntityManager() returns spring injected EntityManager, database field history type is: text or varchar2(20
If you are willing to use the PreparedStatement class instead of Query:
if (entity.getHistory() == null) stmt.setNull(6, Types.VARCHAR); else stmt.setString(6, entity.getHistory());
(It is possible that using ?::text in your query string would also work, but I've never done it that way myself.)
?::text