We have already discussed is that in the hibernate every thing is possible which we want to do. So if It is possible to eagerly join in the Person to avoid the possible extra roundtrip for initializing the proxy. This is done via the addJoin() method, which allows you to join in an association or collection.
sess.createSQLQuery("SELECT c.ID, NAME, BIRTHDATE, PERSON_ID, D_ID, D_NAME FROM STUDENTS c, PERSONS d WHERE c.PERSON_ID = d.D_ID")
With the help of the above code of the example the returned Student's will have their dog property fully initialized without any extra roundtrip to the database. But we have to remember that added an alias name ("student") to be able to specify the target property path of the join. It is possible to do the same eager joining for collections, e.g. if the Student had a one-to-many to Person instead.
sess.createSQLQuery("SELECT ID, NAME, BIRTHDATE, D_ID, D_NAME, STUDENT_ID FROM STUDENTS c, PERSONS d WHERE c.ID = d.STUDENT_ID")
We reaching the limits of what is possible with native queries, without starting to enhance the sql queries to make them usable in Hibernate. Problems can arise when returning multiple entities of the same type or when the default alias/column names are not enough.