Room Rxjava Single as Delete Response
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
|
show 1 more comment
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
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
withDELETE
method toSingle<Integer>
. Have you tried to change it toint
orInteger
?
– 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 neitherLong
,Short
andByte
– Andrey Ilyunin
Nov 26 '18 at 16:35
|
show 1 more comment
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
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
android android-room
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
withDELETE
method toSingle<Integer>
. Have you tried to change it toint
orInteger
?
– 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 neitherLong
,Short
andByte
– Andrey Ilyunin
Nov 26 '18 at 16:35
|
show 1 more comment
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
withDELETE
method toSingle<Integer>
. Have you tried to change it toint
orInteger
?
– 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 neitherLong
,Short
andByte
– 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
|
show 1 more comment
2 Answers
2
active
oldest
votes
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));
});
}
}
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
add a comment |
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".
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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));
});
}
}
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
add a comment |
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));
});
}
}
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
add a comment |
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));
});
}
}
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));
});
}
}
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
add a comment |
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
add a comment |
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".
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.
add a comment |
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".
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.
add a comment |
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".
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.
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".
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.
edited Nov 27 '18 at 5:07
answered Nov 27 '18 at 5:01
jakejake
3939
3939
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
withDELETE
method toSingle<Integer>
. Have you tried to change it toint
orInteger
?– 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
andByte
– Andrey Ilyunin
Nov 26 '18 at 16:35