ISessionDao implementation issue

Hi,


I’m trying to implement ISessionDao, connector is saved in the HTTP Session, so an instance is created per user session. Thus, we created a sample implementation as below:

public class CustomTempSessionDaoImpl implements ISessionDao {
protected List sessions = new ArrayList();

public CustomTempSessionDaoImpl() {
}

@Override
public void createTableIfNotExists() throws AnnotationException {
}

@Override
public int delete(ISession paramT) {
sessions.remove(paramT);
return 0;
}

@Override
public int insert(ISession paramT) {
sessions.add(paramT);
return 0;
}

@Override
public List selectAllBy(List paramList, Object… paramVarArgs) throws AnnotationException {
return sessions;
}

@Override
public ISession selectBy(List paramList, Object… paramVarArgs) throws AnnotationException {
return sessions.size() > 0 ? sessions.get(0) : null;
}

@Override
public int update(ISession paramT) {
return 0;
}
}

But it fails with the following exception:

SEVERE: Annotation throws exception: AnnotationSession is not found!
com.groupdocs.annotation.exception.AnnotationException: AnnotationSession is not found!
at com.groupdocs.annotation.api.shared.CommonApi.viewDocument(CommonApi.java:295)
at com.groupdocs.annotation.api.shared.WebApi.viewDocumentHandler(WebApi.java:263)
at com.groupdocs.annotation.handler.AnnotationHandler.viewDocumentHandler(AnnotationHandler.java:157)
at com.groupdocs.HomeController.viewDocumentHandler(HomeController.java:897)



What is wrong with our implementation? We see that correctly “insert” method is invoked first, then “selectBy”, so the correct session instance is returned. Any idea?

Thanks,
Mariusz
Hello Mariusz,

Sorry to see you get this problem, please show also your ICustomConnector implementation, if you just used the one from the sample – then you can see that the ISessionDao object is created every time the getSessionDao() method is called.