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.
Hibernate doesn't know anything about this view, but I'd want to do something like this:
public List<Object> getCsvView() {
return (List<Object>) getHibernateTemplate().find("from myView");
}
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:
You can also map a native query[...]To achieve that, you need to describe the SQL resultset structure using @SqlResultSetMapping[...].
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.
Furthermore they might change this view at any time. I'm really not thrilled about my app even knowing about the view.
So, is there an easy way to do this in the Spring/Hibernate world, or am I attacking this problem the hard way?