Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AbstractQuery.getDao() #345

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cwlockhart
Copy link

Used to check if the dao database isn't already closed to validate a saved query object.

Used to check if the dao database isn't already closed to validate a
saved query object.
@greenrobot
Copy link
Owner

Sorry, don't want to expose that. One can always store the dao beforehand.

@greenrobot greenrobot closed this Jul 28, 2016
@jeffdgr8
Copy link

@greenrobot Can you please explain why exposing the dao property would be a problem? Storing the dao alongside a saved query object, when the query object itself already has a reference to it would be a dirty solution to this problem.

The problem that needs to be solved is being able to find out if a saved query object is referencing a database that has already been closed or not. Before attempting to reuse a saved query, this needs to be checked, as it's possible the database has been closed in our app.

Invalidating all saved query objects upon closing the database is also a complicated solution, as we'd have to be sure to add every saved query reference to the database closing method, and it would be easy to forget when adding them later.

It's much easier to make this check before attempting to reuse a query. Is there some other way you could propose knowing if a query object is still reusable with a currently opened database or if it is referencing a database which is no longer open?

@greenrobot
Copy link
Owner

I was almost convinced, but public AbstractDao<T, ?> getDao() is ugly. It is missing the K (key type). How about getAbstractDaoSession ?

@greenrobot greenrobot reopened this Jul 28, 2016
@jeffdgr8
Copy link

That should work as well for this need, since ultimately it would be the dao session that would be gotten from the dao to perform this check.

public AbstractDaoSession getSession() {
    return dao.getSession();
}

@cwlockhart
Copy link
Author

cwlockhart commented Aug 4, 2016

I've made the requested changes from getDao() to getSession() so the dao is no longer exposed, but we can validate the session before trying to reuse a saved query object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants