Room Rxjava Single as Delete Response












2















I am faceing some issues with compile time errors from the Room Library.



I am using Version: 2.1.0-alpha02



The following Dao causes the error:



@Dao()
public interface WorkoutExerciseDao {

[......]
@Update()
Single<Integer> updateWorkout(final WorkoutExercise... workoutExercises);


@Delete
Single<Integer> deleteWorkouts(final WorkoutExercise... user);

@Query("DELETE FROM workout_exercise_table WHERE id IN(:exerciseIds)")
Single<Integer> deleteWorkouts(final long... exerciseIds);
}


Currently the first @Delete annotated Method compiles fine and works as expected. If I add the second one(Delete inside the query method) it breaks compilation with an error:




Deletion methods must either return void or return int (the number of
deleted rows).




Do I miss something here?










share|improve this question




















  • 2





    Here's single @Delete-annotated method. What do you mean by "second"?

    – Andrey Ilyunin
    Nov 26 '18 at 11:44











  • I meant the Query one that contains a DELETE Statement. sorry, should have been clearer about that

    – LeDon
    Nov 26 '18 at 14:40











  • I suppose that Room's RxJava codegeneration isn't smart enough to adapt @Query with DELETE method to Single<Integer>. Have you tried to change it to int or Integer?

    – Andrey Ilyunin
    Nov 26 '18 at 16:17











  • Just wondering as the same error occured for the Delete annotated method when I returned Single<Long>. So it does seem to be able to map those for Delete methods

    – LeDon
    Nov 26 '18 at 16:31











  • Yep, seems and it does not expect neither Long, Short and Byte

    – Andrey Ilyunin
    Nov 26 '18 at 16:35
















2















I am faceing some issues with compile time errors from the Room Library.



I am using Version: 2.1.0-alpha02



The following Dao causes the error:



@Dao()
public interface WorkoutExerciseDao {

[......]
@Update()
Single<Integer> updateWorkout(final WorkoutExercise... workoutExercises);


@Delete
Single<Integer> deleteWorkouts(final WorkoutExercise... user);

@Query("DELETE FROM workout_exercise_table WHERE id IN(:exerciseIds)")
Single<Integer> deleteWorkouts(final long... exerciseIds);
}


Currently the first @Delete annotated Method compiles fine and works as expected. If I add the second one(Delete inside the query method) it breaks compilation with an error:




Deletion methods must either return void or return int (the number of
deleted rows).




Do I miss something here?










share|improve this question




















  • 2





    Here's single @Delete-annotated method. What do you mean by "second"?

    – Andrey Ilyunin
    Nov 26 '18 at 11:44











  • I meant the Query one that contains a DELETE Statement. sorry, should have been clearer about that

    – LeDon
    Nov 26 '18 at 14:40











  • I suppose that Room's RxJava codegeneration isn't smart enough to adapt @Query with DELETE method to Single<Integer>. Have you tried to change it to int or Integer?

    – Andrey Ilyunin
    Nov 26 '18 at 16:17











  • Just wondering as the same error occured for the Delete annotated method when I returned Single<Long>. So it does seem to be able to map those for Delete methods

    – LeDon
    Nov 26 '18 at 16:31











  • Yep, seems and it does not expect neither Long, Short and Byte

    – Andrey Ilyunin
    Nov 26 '18 at 16:35














2












2








2








I am faceing some issues with compile time errors from the Room Library.



I am using Version: 2.1.0-alpha02



The following Dao causes the error:



@Dao()
public interface WorkoutExerciseDao {

[......]
@Update()
Single<Integer> updateWorkout(final WorkoutExercise... workoutExercises);


@Delete
Single<Integer> deleteWorkouts(final WorkoutExercise... user);

@Query("DELETE FROM workout_exercise_table WHERE id IN(:exerciseIds)")
Single<Integer> deleteWorkouts(final long... exerciseIds);
}


Currently the first @Delete annotated Method compiles fine and works as expected. If I add the second one(Delete inside the query method) it breaks compilation with an error:




Deletion methods must either return void or return int (the number of
deleted rows).




Do I miss something here?










share|improve this question
















I am faceing some issues with compile time errors from the Room Library.



I am using Version: 2.1.0-alpha02



The following Dao causes the error:



@Dao()
public interface WorkoutExerciseDao {

[......]
@Update()
Single<Integer> updateWorkout(final WorkoutExercise... workoutExercises);


@Delete
Single<Integer> deleteWorkouts(final WorkoutExercise... user);

@Query("DELETE FROM workout_exercise_table WHERE id IN(:exerciseIds)")
Single<Integer> deleteWorkouts(final long... exerciseIds);
}


Currently the first @Delete annotated Method compiles fine and works as expected. If I add the second one(Delete inside the query method) it breaks compilation with an error:




Deletion methods must either return void or return int (the number of
deleted rows).




Do I miss something here?







android android-room






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 14:41







LeDon

















asked Nov 26 '18 at 11:36









LeDonLeDon

165316




165316








  • 2





    Here's single @Delete-annotated method. What do you mean by "second"?

    – Andrey Ilyunin
    Nov 26 '18 at 11:44











  • I meant the Query one that contains a DELETE Statement. sorry, should have been clearer about that

    – LeDon
    Nov 26 '18 at 14:40











  • I suppose that Room's RxJava codegeneration isn't smart enough to adapt @Query with DELETE method to Single<Integer>. Have you tried to change it to int or Integer?

    – Andrey Ilyunin
    Nov 26 '18 at 16:17











  • Just wondering as the same error occured for the Delete annotated method when I returned Single<Long>. So it does seem to be able to map those for Delete methods

    – LeDon
    Nov 26 '18 at 16:31











  • Yep, seems and it does not expect neither Long, Short and Byte

    – Andrey Ilyunin
    Nov 26 '18 at 16:35














  • 2





    Here's single @Delete-annotated method. What do you mean by "second"?

    – Andrey Ilyunin
    Nov 26 '18 at 11:44











  • I meant the Query one that contains a DELETE Statement. sorry, should have been clearer about that

    – LeDon
    Nov 26 '18 at 14:40











  • I suppose that Room's RxJava codegeneration isn't smart enough to adapt @Query with DELETE method to Single<Integer>. Have you tried to change it to int or Integer?

    – Andrey Ilyunin
    Nov 26 '18 at 16:17











  • Just wondering as the same error occured for the Delete annotated method when I returned Single<Long>. So it does seem to be able to map those for Delete methods

    – LeDon
    Nov 26 '18 at 16:31











  • Yep, seems and it does not expect neither Long, Short and Byte

    – Andrey Ilyunin
    Nov 26 '18 at 16:35








2




2





Here's single @Delete-annotated method. What do you mean by "second"?

– Andrey Ilyunin
Nov 26 '18 at 11:44





Here's single @Delete-annotated method. What do you mean by "second"?

– Andrey Ilyunin
Nov 26 '18 at 11:44













I meant the Query one that contains a DELETE Statement. sorry, should have been clearer about that

– LeDon
Nov 26 '18 at 14:40





I meant the Query one that contains a DELETE Statement. sorry, should have been clearer about that

– LeDon
Nov 26 '18 at 14:40













I suppose that Room's RxJava codegeneration isn't smart enough to adapt @Query with DELETE method to Single<Integer>. Have you tried to change it to int or Integer?

– Andrey Ilyunin
Nov 26 '18 at 16:17





I suppose that Room's RxJava codegeneration isn't smart enough to adapt @Query with DELETE method to Single<Integer>. Have you tried to change it to int or Integer?

– Andrey Ilyunin
Nov 26 '18 at 16:17













Just wondering as the same error occured for the Delete annotated method when I returned Single<Long>. So it does seem to be able to map those for Delete methods

– LeDon
Nov 26 '18 at 16:31





Just wondering as the same error occured for the Delete annotated method when I returned Single<Long>. So it does seem to be able to map those for Delete methods

– LeDon
Nov 26 '18 at 16:31













Yep, seems and it does not expect neither Long, Short and Byte

– Andrey Ilyunin
Nov 26 '18 at 16:35





Yep, seems and it does not expect neither Long, Short and Byte

– Andrey Ilyunin
Nov 26 '18 at 16:35












2 Answers
2






active

oldest

votes


















5














you are right and I had this problem. I don't know reason but I know there isn't any way in latest version of room to handle this problem and when you use query for DELETE it says return type must be void or int but if you want use RX for DELETE query you can do like this but maybe not best way:
first convert interface to abstract class and also all methods to abstract method then



@Dao
public abstract class WorkoutExerciseDao {

@Update()
abstract Single<Integer> updateWorkout(final WorkoutExercise... workoutExercises);

@Delete
abstract Single<Integer> deleteWorkouts(final WorkoutExercise... user);

@Query("DELETE FROM workout_exercise_table WHERE id IN(:exerciseIds)")
abstract Integer deleteWorkouts(final long... exerciseIds);

Single<Integer> deleteWorkoutsById(final long... exerciseIds) {
return Single.create(emitter -> {
emitter.onSuccess(deleteWorkouts(exerciseIds));
});
}
}





share|improve this answer
























  • Thanks. I was doing something like this as a workaround in the meantime. I submitted a bug report in the official tracker and it got promoted. Maybe this will be fixed by the time the non beta/alpha version gets released.

    – LeDon
    Nov 27 '18 at 16:54



















-1














You need to use AndroidX



Migrate your project to AndroidX first refer to the documentation, the easy way is to right click your project folder make sure it is in projects perspective, right click the folder and click Refactor and there should be an option "Migrate to AndroidX".



enter image description here



After migrating your project to AndroidX you can now add the AndroidX dependencies in your app level gradle.



implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version" // kapt for Kotlin
// optional - RxJava support for Room
implementation "androidx.room:room-rxjava2:$room_version"


See the documentation for adding latest version dependencies for Room.






share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53480265%2froom-rxjava-single-as-delete-response%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    you are right and I had this problem. I don't know reason but I know there isn't any way in latest version of room to handle this problem and when you use query for DELETE it says return type must be void or int but if you want use RX for DELETE query you can do like this but maybe not best way:
    first convert interface to abstract class and also all methods to abstract method then



    @Dao
    public abstract class WorkoutExerciseDao {

    @Update()
    abstract Single<Integer> updateWorkout(final WorkoutExercise... workoutExercises);

    @Delete
    abstract Single<Integer> deleteWorkouts(final WorkoutExercise... user);

    @Query("DELETE FROM workout_exercise_table WHERE id IN(:exerciseIds)")
    abstract Integer deleteWorkouts(final long... exerciseIds);

    Single<Integer> deleteWorkoutsById(final long... exerciseIds) {
    return Single.create(emitter -> {
    emitter.onSuccess(deleteWorkouts(exerciseIds));
    });
    }
    }





    share|improve this answer
























    • Thanks. I was doing something like this as a workaround in the meantime. I submitted a bug report in the official tracker and it got promoted. Maybe this will be fixed by the time the non beta/alpha version gets released.

      – LeDon
      Nov 27 '18 at 16:54
















    5














    you are right and I had this problem. I don't know reason but I know there isn't any way in latest version of room to handle this problem and when you use query for DELETE it says return type must be void or int but if you want use RX for DELETE query you can do like this but maybe not best way:
    first convert interface to abstract class and also all methods to abstract method then



    @Dao
    public abstract class WorkoutExerciseDao {

    @Update()
    abstract Single<Integer> updateWorkout(final WorkoutExercise... workoutExercises);

    @Delete
    abstract Single<Integer> deleteWorkouts(final WorkoutExercise... user);

    @Query("DELETE FROM workout_exercise_table WHERE id IN(:exerciseIds)")
    abstract Integer deleteWorkouts(final long... exerciseIds);

    Single<Integer> deleteWorkoutsById(final long... exerciseIds) {
    return Single.create(emitter -> {
    emitter.onSuccess(deleteWorkouts(exerciseIds));
    });
    }
    }





    share|improve this answer
























    • Thanks. I was doing something like this as a workaround in the meantime. I submitted a bug report in the official tracker and it got promoted. Maybe this will be fixed by the time the non beta/alpha version gets released.

      – LeDon
      Nov 27 '18 at 16:54














    5












    5








    5







    you are right and I had this problem. I don't know reason but I know there isn't any way in latest version of room to handle this problem and when you use query for DELETE it says return type must be void or int but if you want use RX for DELETE query you can do like this but maybe not best way:
    first convert interface to abstract class and also all methods to abstract method then



    @Dao
    public abstract class WorkoutExerciseDao {

    @Update()
    abstract Single<Integer> updateWorkout(final WorkoutExercise... workoutExercises);

    @Delete
    abstract Single<Integer> deleteWorkouts(final WorkoutExercise... user);

    @Query("DELETE FROM workout_exercise_table WHERE id IN(:exerciseIds)")
    abstract Integer deleteWorkouts(final long... exerciseIds);

    Single<Integer> deleteWorkoutsById(final long... exerciseIds) {
    return Single.create(emitter -> {
    emitter.onSuccess(deleteWorkouts(exerciseIds));
    });
    }
    }





    share|improve this answer













    you are right and I had this problem. I don't know reason but I know there isn't any way in latest version of room to handle this problem and when you use query for DELETE it says return type must be void or int but if you want use RX for DELETE query you can do like this but maybe not best way:
    first convert interface to abstract class and also all methods to abstract method then



    @Dao
    public abstract class WorkoutExerciseDao {

    @Update()
    abstract Single<Integer> updateWorkout(final WorkoutExercise... workoutExercises);

    @Delete
    abstract Single<Integer> deleteWorkouts(final WorkoutExercise... user);

    @Query("DELETE FROM workout_exercise_table WHERE id IN(:exerciseIds)")
    abstract Integer deleteWorkouts(final long... exerciseIds);

    Single<Integer> deleteWorkoutsById(final long... exerciseIds) {
    return Single.create(emitter -> {
    emitter.onSuccess(deleteWorkouts(exerciseIds));
    });
    }
    }






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 27 '18 at 4:43









    saeedatasaeedata

    44137




    44137













    • Thanks. I was doing something like this as a workaround in the meantime. I submitted a bug report in the official tracker and it got promoted. Maybe this will be fixed by the time the non beta/alpha version gets released.

      – LeDon
      Nov 27 '18 at 16:54



















    • Thanks. I was doing something like this as a workaround in the meantime. I submitted a bug report in the official tracker and it got promoted. Maybe this will be fixed by the time the non beta/alpha version gets released.

      – LeDon
      Nov 27 '18 at 16:54

















    Thanks. I was doing something like this as a workaround in the meantime. I submitted a bug report in the official tracker and it got promoted. Maybe this will be fixed by the time the non beta/alpha version gets released.

    – LeDon
    Nov 27 '18 at 16:54





    Thanks. I was doing something like this as a workaround in the meantime. I submitted a bug report in the official tracker and it got promoted. Maybe this will be fixed by the time the non beta/alpha version gets released.

    – LeDon
    Nov 27 '18 at 16:54













    -1














    You need to use AndroidX



    Migrate your project to AndroidX first refer to the documentation, the easy way is to right click your project folder make sure it is in projects perspective, right click the folder and click Refactor and there should be an option "Migrate to AndroidX".



    enter image description here



    After migrating your project to AndroidX you can now add the AndroidX dependencies in your app level gradle.



    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version" // kapt for Kotlin
    // optional - RxJava support for Room
    implementation "androidx.room:room-rxjava2:$room_version"


    See the documentation for adding latest version dependencies for Room.






    share|improve this answer






























      -1














      You need to use AndroidX



      Migrate your project to AndroidX first refer to the documentation, the easy way is to right click your project folder make sure it is in projects perspective, right click the folder and click Refactor and there should be an option "Migrate to AndroidX".



      enter image description here



      After migrating your project to AndroidX you can now add the AndroidX dependencies in your app level gradle.



      implementation "androidx.room:room-runtime:$room_version"
      annotationProcessor "androidx.room:room-compiler:$room_version" // kapt for Kotlin
      // optional - RxJava support for Room
      implementation "androidx.room:room-rxjava2:$room_version"


      See the documentation for adding latest version dependencies for Room.






      share|improve this answer




























        -1












        -1








        -1







        You need to use AndroidX



        Migrate your project to AndroidX first refer to the documentation, the easy way is to right click your project folder make sure it is in projects perspective, right click the folder and click Refactor and there should be an option "Migrate to AndroidX".



        enter image description here



        After migrating your project to AndroidX you can now add the AndroidX dependencies in your app level gradle.



        implementation "androidx.room:room-runtime:$room_version"
        annotationProcessor "androidx.room:room-compiler:$room_version" // kapt for Kotlin
        // optional - RxJava support for Room
        implementation "androidx.room:room-rxjava2:$room_version"


        See the documentation for adding latest version dependencies for Room.






        share|improve this answer















        You need to use AndroidX



        Migrate your project to AndroidX first refer to the documentation, the easy way is to right click your project folder make sure it is in projects perspective, right click the folder and click Refactor and there should be an option "Migrate to AndroidX".



        enter image description here



        After migrating your project to AndroidX you can now add the AndroidX dependencies in your app level gradle.



        implementation "androidx.room:room-runtime:$room_version"
        annotationProcessor "androidx.room:room-compiler:$room_version" // kapt for Kotlin
        // optional - RxJava support for Room
        implementation "androidx.room:room-rxjava2:$room_version"


        See the documentation for adding latest version dependencies for Room.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 27 '18 at 5:07

























        answered Nov 27 '18 at 5:01









        jakejake

        3939




        3939






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53480265%2froom-rxjava-single-as-delete-response%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Costa Masnaga

            Fotorealismo

            Sidney Franklin