1: The problem lies in cglib. You can fix the problem and update cglib from 2.1.3 To 2.2.beta1 using hibernate3.1.
2: set lazy = "false" for the relevant table to solve the problem.
In general, it is delayed loading. There is no problem when writing the test class, but an error occurs when the application is applied to the web page. Or upgrade the hibernate version to correct this error.
Related: hibernate lazy fetch
1. Fetch has a higher priority than lazy. In general cases (except in general cases, as described in the next article) Fetch has a higher priority than lazy. In case of fetch, lazy is ignored.
2. In the configuration file, lazy must be explicitly declared as false or true. In the case of multiple pairs, lazy is neither true nor false by default. If you do not explicitly state that it is executed in the lazy = true method, but if you explicitly write lazy = true, an error is returned, in general, lazy = false is clearly written.
3. YourCodeIf student = (student) session. get (student. class, 1), Hibernate will correctly execute according to the configuration file policy, fetch is executed when fetch is available, and lazy is executed when lazy is available; but if your code is like Query query = session. createquery ("from student"), which ignores the fetch in the configuration file, does not execute fetch = join, lazy is correctly executed, and student attributes (this is assumed to be team, the fetch in the configuration file is executed correctly.
4. query = session. createquery ("from student s left Outer Join s. the fetch of the configuration files of student and team classes will be ignored, but the lazy in these classes will be correctly executed.