After working with 3 layers, DAO, JPA and Hibernate and stuff, I think writing native SQL code is going to disappear. However, til today, I just found a new framework that support you to write SQL command by Java code. Their fluent API is so good that it seems identical with real SQL command.
Check out JOOQ – Java Object Oriented Querying;
P.s: Guess what! It’s type-safe.