• may be you need to increase the max varchar size in the postgres driver

    and

    change the code to

    substr("Text",1,4000)