Why not create stored procedure and call it from CallableStatement with String param to insert row with ltree via it, if preparedStatemnt.setString() isn't working?
Other solution may be ps.setObject(2, foos.get(i).getPath(), Types.OTHER);
, but I can't check it now.