I have a set mapping one to many relationship, with lazy initialization.
Code:
<set
inverse="true"
lazy="true"
name="EspecialidadeMedica"
where="Chvtpespec=1"
>
<key column="chvpfisica" />
<one-to-many class="Especialidade" />
</set>
My client code don't know if the set was initialized. Is there a way to check it avoiding the "no session associated" exception ?
Code:
//Current code
boolean isLoaded=false;
if (!myObj.getEspecialidadeMedica().isEmpty()) {
isLoaded=true;
}
// Something like that, but is this bad ? bcause I'm referencing an internal
// hibernate class I think
PersistentCollection col = (PersistentCollection) myObj.getEspecialidadeMedica();
if ( col.wasInitialized()) {
isLoaded=true;
}
something using the session will not work (?) since the object is already detached.
Thanks