Hi. I am using Hibernate and Spring in a project right now and I am having some trouble with Session.load(). There's this object called HibernateTemplate which wraps around Session and helps you control your session (it opens and closes it on every method call).
Since all I need is to load one single object, I think there's no problem using this HibernateTemplate object. It has a load() method just like Session but the thing is that it closes the session before returning the object. So once you get the object back, it is already detached from its Session and you are not able to get ANY of it's properties (not only collections, but ANY of them) without getting a "LazyInitializationException".
So what's the point of having a load() method if it doesn't load your object properties, not even the simple ones? I can understand why Hibernate tries to lazy load collections, but what about Strings, Integers and all those simple properties?
Thanx in advance
Rodrigo
-------------
Hibernate version: 3
Mapping documents: <hibernate-mapping package="com.corbitecso.coredu.modelo"> <class name="Curso" table="curso"> <id name="idCurso" column="id_curso"> <generator class="increment" /> </id>
<property name="nombre" column="course_name"/> <property name="descripcion"/> <set name="estudiantes" table="estudiante_cursos" inverse="true"> <key column="id_curso" /> <many-to-many column="id_estudiante" class="com.corbitecso.coredu.modelo.Estudiante" /> </set> </class> </hibernate-mapping>
Name and version of the database you are using: mysql 5
The generated SQL (show_sql=true): I think it is generating an SQL which has all those simple properties in it, but still it is not loading them in the object
Debug level Hibernate log excerpt: ¿?
|