android - Transactions with GreenDao -
i made post because don't understand how transaction works using greendao , love explanation/recent tutorial.
despite of reading greendao github, don't understand how main activity works. example:
... note note = new note(null, notetext, comment, new date(), notetype.text); notedao.insert(note) .observeon(androidschedulers.mainthread()) .subscribe(new action1<note>() { @override public void call(note note) { log.d("daoexample", "inserted new note, id: " + note.getid()); updatenotes(); } }); ... do observeon method sends every insertion/update 1 limited buffer? so, manage automatically insertion real database when every operation finished whithout problems?
reading api, see use rxtx , rxtxplain transactions (other way?), , finding out performed, have misunderstood everything. example:
... public void testconcurrentinsertduringtx() throws interruptedexception { ... runnable runnable2 = new runnable() { @override public void run() { dao.insertintx(createentity(null)); } }; runnable runnable3 = new runnable() { @override public void run() { daosession.runintx(new runnable() { @override public void run() { dao.insert(createentity(null)); } }); } }; ... // builds statement ready in thread dao.insert(createentity(null)); dotx(new runnable() { @override public void run() { dao.insert(createentity(null)); } }); latchthreadsdone.await(); assertequals(7, dao.count()); } ... i know example, but don't know diferences of using rx methods , observeon/subscribe ones
protected void dotx(final runnable runnableinsidetx) { daosession.runintx(new runnable() { @override public void run() { latchinsidetx.countdown(); // give concurrent thread time try acquire locks try { thread.sleep(time_to_wait_for_thread); } catch (interruptedexception e) { throw new runtimeexception(e); } runnableinsidetx.run(); } }); } i read topics transactions, obsoletes or maybe, didn't understand them correctly:
sqlite transaction behaviour using greendao
android - green dao multiple transaction
greendao 40 seconds insert 600 records
https://groups.google.com/forum/#!topic/greendao/pxrwcrtbp6c
someone me giving me explanation/recent tutorial? greendao have these methods experimentals. in advance
Comments
Post a Comment