| Setting the FetchMode different from the FetchType in the annotated classes is not working when the session is closed already. When FetchType is LAZY in the annotated classes and Fetchmode in the criteria is set to JOIN the resultset performs an error. even if the Fetchmode JOIN should also receive the information from the other class linked to the first one: Hibernate exception !failed to lazily initialize a collection of role: annotations.Company.employees, could not initialize proxy - no Session The other way around: When FetchType is EAGER in the annotated classes and Fetchmode in the criteria is set to LAZY the resultset contains also the data from the second table because of the EAGER FetchType in the classes. Setting the fechMode in the criteria is not working. I added a Word document with some tests I did. In addition I added the source files to redo the test. Read the hibernate.cfg.xml file to see which database you need to create first. DBName = dbhibernateFetchTypeJoin when accesing the resultset after the session has been committed. |