The Java program actually just executes "SELECT b FROM public.a" and keeps streaming more rows doing something with the content, also the execution plan for my query is fairly simple - actually it seems to be just a sequential scan (with both versions).
Could you include as an attachment a complete compilable java program? Including the imports, the main public class definition, etc.