title: MySQL view to CSV file using Java, Spring, and Hibernate
body: <p>I've been asked to output a CSV file from a view in MySQL.  The app I currently am writing uses Spring and Hibernate to create the database, but the view is just handed to me. </p>
  
  <p>Hibernate doesn't know anything about this view, but I'd want to do something like this:</p>
  
  <pre><code>public List&lt;Object&gt; getCsvView() {
    return (List&lt;Object&gt;) getHibernateTemplate().find("from myView");
  }
  </code></pre>
  
  <p>My guess was that I could map a native query so that hibernate knows about the view.  This got a little tricky when I read the docs:</p>
  
  <blockquote>
    <p>You can also map a native query[...]To
    achieve that, you need to describe the
    SQL resultset structure using
    @SqlResultSetMapping[...].</p>
  </blockquote>
  
  <p>Now, I'm really not interested in mapping the structure of the result.  I'm happy to have the structure just be a bunch of objects.</p>
  
  <p>Furthermore they might change this view at any time.  I'm really not thrilled about my app even knowing about the view.</p>
  
  <p>So, is there an easy way to do this in the Spring/Hibernate world, or am I attacking this problem the hard way?</p>