here is an interesting situation
Code:
<class name="abc.def.Class1" ........>
<id column="....></id>
<property column="......"/>
<property column="......"/>
<set name="myName" lazy="false" inverse="true">
<key column = "myname_uid"/>
<one-to-many class="abc.def.Class2"/>
</set>
</class>
I execute a Query and got a List of abc.def.Class1
and each abc.def.Class1 had one or more abc.def.Class2
Let us consider the case when abc.def.Class1 is loaded.
I ran my app in debug mode, i saw that a prepared statement was created to load abc.def.Class1
I have to load 10 abc.def.Class2 objects in a set corresponding to the load of one abc.def.Class1 (as per the one-to-many relation)
When abc.def.Class1 loads, I saw totally 11 times prepared statements being created. I think 11 db calls were made.
When we do this in a normal DAO, we would have at the max of 2 db calls.
Can any one let me know how Hibernate will lode data / make db calls?
I am sure that Hibernate is faster in DB access. so why did it try to make 11 prepared statements? Could any one please guide me to know how this works? Any help would be much appreciated.