Hello,
I've ran a basic test with NHibernate comparing criteria vs hql. Here's my criteria call:
Code:
sessionFactory.GetCurrentSession().CreateCriteria<User>().List<User>();
If I retrieve the entity with a criteria query, it executes only a single query, retrieving the entity and all it's mapped many-to-ones in a single query.
Code:
sessionFactory.GetCurrentSession().CreateQuery("from User").List<User>();
This HQL query will get the same list, but it makes several queries to the database, one for the list of users and then more for retrieving individual objects mapped as many-to-ones in the User mappings file.
Is a HQL query suppose to ignore an entity's mapping file? Is there a way to make it honor the mapping file or do I have to include a bunch of join fetches for every HQL statement?
Sorry if this was answered somewhere in the documentation, but I couldn't find it.