Returning non-managed entities in SQL by R4R Team

It is possible to apply a ResultTransformer to native SQL queries, allowing it to return non-managed entities.

sess.createSQLQuery("SELECT NAME, BIRTHDATE FROM STUDENTS")
        .setResultTransformer(Transformers.aliasToBean(StudentDTO.class))

This query specified:

1. the SQL query string
2. a result transformer

The above query will return a list of StudentDTO which has been instantiated and injected the values of NAME and BIRTHNAME into its corresponding properties or fields.
Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!