I am using a Model File namely Document.java and Document.hbm.xml from a jar file .
This document class has an object:
class Document{
private Signature signature;
// other fields
// getter setters
}
with hbm mapping as follows:
<many-to-one name="signature" column="SIGNATURE_ID" class="com.model.Signature"/>
Now as I am accessing these files from jar so I prefer not to change them .
I am taking out the Document object as follows:
Query qry = getSessionFactory().getCurrentSession().createQuery("from
Document where id = :id");
qry.setParameter("id" , id);
return (Document)qry.list().get(0);
But now when I take out a Signature object through following code:
I have a utility class Utils.java so I am accessing it as :
Utils utils = new Utils();
utils.getSignatures(document);
and this getSignatures method inside Utils class is
public Signatures getSignatures (Document document){
Signature sign = document.getSignature();
// working on sign object
return sign;
}
So now as in above code when ever I do document.getSignature() I get the following error:
org.hibernate.LazyInitializationException: could not initialize proxy - no Session