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

Add all() and first() convenience methods and make save() overridable #424

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tacoman667
Copy link

Added convenience method for first() and all(). changed save() from final to overridable. Sometimes one might want to be able to wrap the save command with additional functionality, like logging, or creation of new relationship objects, etc.

…inal to overridable. Sometimes one might want to be able to wrap the save command with additional functionality, like logging, or creation of new relationship objects, etc.
@saulojg
Copy link

saulojg commented Oct 20, 2015

Sounds useful, though I've wondered for a while what were the motivations behind making these methods final. I wish they weren't final so that I could add beforeSave and afterSave callbacks on a few models (perhaps annotated with @CallSuper?).

@tacoman667
Copy link
Author

Forgive me if I am not completely up to speed on Java. I am more versed in C#, Ruby, JavaScript, etc. Does @callsuper annotation make all overrides fail the compile step if the overridden method doesn't call super.overriddenMethod()?

Personally, I override save() on a few of my models so that I can add event logging for a business application. This was my motivation to open save() back up again and remove that final declaration.

@joshuapinter
Copy link
Contributor

@tacoman667 Hey, I like your additions. Any idea how I would easily include your fork? I'm used to npm and RubyGems right now so can't figure out this .jar and Maven stuff.

@tacoman667
Copy link
Author

@joshuapinter Unfortunately, you will have to build the jar or include the source into your project and reference it locally. That's what I did for my Android project. Our fork is at https://github.com/surgeforward/ActiveAndroid with these small changes in this PR or you can just add the few lines of code to your own fork.

@joshuapinter
Copy link
Contributor

@tacoman667 Thanks for the response. Yeah, I figured it's not as easy as updating the GitHub branch on a package.json file. :)

I had trouble building the .jar, likely because the Gradle build tools and config are so out of date so I'll try referencing the local project and see how that goes. Thanks.

@joshuapinter
Copy link
Contributor

@tacoman667 Just an update, include the library and have everything working great, including your updates and some other things, like returning the saved object on save() instead of the object's id. Plus, now I can make super quick updates to the library without leaving my project and having to generate a .jar file. Definitely the way to go.

@tacoman667
Copy link
Author

@joshuapinter Glad I could help! Sad that this project seems dead though. :(

TBH, I am more into RealmDB on mobile devices these days...

@joshuapinter
Copy link
Contributor

@tacoman667 Me too, actually. I use Realm (and their sync platform) for my side project, ntwrk. Cross platform, React Native with built-in sync. It's not perfect but it's pretty damn good and getting better all the time. Plus, no need for a ORM, its native methods are good enough.

We're still heavily engrained with ActiveAndroid on my work's mobile app and, to be fair, it's been great. However, will eventually migrate over to Realm as we convert things to React Native and consolidate our platform support.

@saulojg
Copy link

saulojg commented May 5, 2017

@joshuapinter @tacoman667 take a look at https://jitpack.io/, it'll let you use your forks in your projects with minimal hassle

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