News: Adding Hibernate native SQL features into your Spring data repository

  1. JPA provides @NamedNativeQuery for you to use native SQL. However, the usage is not so convenient, especially when you need to map multiple entities in your native SQL. You have to define a set of SqlResultSetMapping mapping which is quite error prone.

    For those who have used Hibernate native SQL features before, you will find that it is much more easier to use than JPA's @NamedNativeQuery. In recent projects, I am using Spring Data JPA. I have added hibernate native query features to my Spring Data base repostory. You can now perform native query in JPA without SqlResultSetMapping.


  2. and make it more complicated ....   

    most people dont need hibernate and here we are putting spring to hibernate. why not add some more crap like transaction managers in jdbc, spring and hibernate working together.....

    what happpned to simple architecture.

    jdbc dao not good enough. ok add spring jdbc template if u have the itch...b ut this crazy ....

  3. Hi Spencer,

    Thanks for your comment. :)   

    The target audience of this post is for those who have try to use "Spring data - JPA" module. Using JDBC template could not retrieve entity objects for JPA. That's why some need JPA and also the "Spring data - JPA" module.