title: I'm in an anti-pattern and I want to get out
body: <p>I am developing a java webapp, using jsp/jquery/ejb/jboss.</p>
  
  <p>I have a web-form that enables the user to select any combination of 100 fields (all from different unrelated tables/objects) from the database. These fields are then output, via a java servlet, to an excel spreadsheet. A stored procedure is executed that always returns all 100 fields.</p>
  
  <p>The web-form sets 100 boolean values in a transfer object(TO) to determine whether data should be then be displayed.  This TO is then referenced to produce the title row of the spreadsheet and also for each row from database which is iterated over.</p>
  
  <p>It all works fine, however it feels wrong.  I cannot think of a viable way which does not reference 100 booleans (N+1 times) to determine whether a field should be included in the outputted spreadsheet. When I say viable I mean, for example, that I don't want to rewrite stored procedure or create 100 different stored procedures.</p>