Giter Site home page Giter Site logo

Comments (8)

ImangazalievM avatar ImangazalievM commented on June 5, 2024 1

I will check it out soon. Unfortunately, I have a lot of work to do now.

from reactiveandroid.

bhapps avatar bhapps commented on June 5, 2024 1

Confirmed, It is due to the missing line code setTransactionSuccessful()
beginTransaction()
/* do sql work here */
ReActiveAndroid.getDatabase(ORMAppDatabase.class).getWritableDatabase().setTransactionSuccessful();
endTransaction()

from reactiveandroid.

ImangazalievM avatar ImangazalievM commented on June 5, 2024 1

@bennith Good job! I will add new API for working with transactions in the new version.

from reactiveandroid.

bhapps avatar bhapps commented on June 5, 2024

Moved code to pass through AsyncTask to stop UI freezing (worked), however, the below,

begin/end transaction, even though the if(class.save() > 0){} passes true on each data item (in List<>), nothing gets actually added or updated (get count of 0)

still persists..

from reactiveandroid.

ImangazalievM avatar ImangazalievM commented on June 5, 2024
  1. Can you create a test project, that reproduces your problem?
  2. To avoid UI freezing you have to perform your operations with a database in the background thread.

from reactiveandroid.

ImangazalievM avatar ImangazalievM commented on June 5, 2024

@bennith can you create a simple project that reproduces your problem, and share it on GitHub?

from reactiveandroid.

bhapps avatar bhapps commented on June 5, 2024

@ImangazalievM

Please see sample project which uses transaction to add data (which still fails), but turning off transactions data is added (getting counts of 15K rows)

Change public static boolean useTransactions = true; in MainApplication to enable/disable transaction

Please see ORMHelpers file and the method public static Boolean setRowData(List<String> getPassedData) which processes the passed data;

https://github.com/Bennith/ORMTransactionExample

from reactiveandroid.

bhapps avatar bhapps commented on June 5, 2024

Maybe it is due to missing the setTransactionSuccessful() to do the actual commit.
I will test this on my side to confirm.

How you can use database transaction in Android

  • If you want to start the transaction there is a method beginTransaction()
  • If you want to commit the transaction there is a method setTransactionSuccessful() which will commit the values in the database
  • If you had start the transaction you need to close the transaction so there is a method endTransaction() which will end your database transaction

If so, can we add this to the documentation transactions

from reactiveandroid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.