My current application is running into issues with its ORM, and we're relying on some pretty hairy SQL to express queries that the ORM can't.  Are there best practices in terms of how to manage the SQL queries?  For example, where do these usually live in relation to other parts of the code?  Are they in separate .sql files, or do you edit them directly in your other source files?  If the latter, does your IDE (or editor) allow syntax highlighting?  Are there schemes for Vim or Eclipse which will perform SQL syntax highlighting given a set of tags (like #begin sql and #end sql, or something similar?)
Logistically, how do you manage embedded SQL?
sql;editor;syntax highlight
I'd typically vote against stored procs or views unless you've got a great database build and migration system in place -- it is just too easy to get things out of synch.Insofar as how to store them in your code, typically I'd vote they travel with the appropriate classes that are touching the database and executing the SQL. I don't see any downside to having the queries reside in the normal source so long as you don't have SQL strewn all over the place in your codebase.