title: build oracle sql query dynamically from java application
body: <p>How do I build oracle pl/sql query dynamically from a java application? The user will be presented with a bunch of columns that are present in different tables in the database. The user can select any set of column and the application should build the complete select query using only the tables that contain the selected columns.
  For example, lets consider that there are 3 tables in the database. The user selects col11, col22. In this case, the application should build the query using Tabl1 and Tabl2 only.
  How do I achieve this?</p>
  
  <pre><code>Tabl1
   - col11
   - col12
   - col13
  
  Tabl2
   - fkTbl1
   - col21
   - col22
   - col23
  
  Tabl3
   - col31
   - col32
   - col33
   - fkTbl1
  </code></pre>