Vijay.k (1) [Avatar] Offline
I am using a Base class - 'AbstractDAO' that contains basic methods like 'insert(Object o),read(Class clazz,Long id),update(Object o),delete(Object o)' that take cares all the Exception handling . Now i have taken a 'StudentDAO' that extends 'AbstractDAO' and calls read method by passing 'Student' pojo class object. i.e below is the code in 'StudentDAO'
public Student getStudent(Long id) throws DataAccessLayerException {

return (Student) read(Student.class,id) ; // calling AbsractDAO - read( )

code in 'AbstractDAO'

protected Object read(Class clazz,Long id) {
Object obj = null ;
startOperation() ;
obj = session.load(clazz,id);
tx.commit() ;
} catch (HibernateException e){
} finally {

return obj ;

But while trying to retrieve the (row)data from Database it is throwing an Exception saying "proxy could not be opened after session is closed ".

i.e iam passing an 'id' such that i can retrieve a record relevant to that id which is available in the database.

Is it because of improper TypeCasting betwen 'Object' and 'Student' types.
If so, tell me how to take care of this problem.

Immediate reply would be appreciated