Skip to content

io.objectbox.exception.DbException: Could not begin read transaction (another read transaction is still active on this thread) (error code -30783) #563

@wb1992321

Description

@wb1992321

ObjectBox Version:2.1.0

@Entity
public class TaskObj {
      @Convert(converter = TagConverter.class, dbType = String.class)
      private List<TagObj> tags;
}
public final class TagConverter implements PropertyConverter<List<TagObj>, String> {

    @Override
    public List<TagObj> convertToEntityProperty(String databaseValue) {
        return ConvertUtils.query(databaseValue, TagObj_.id, TagObj.class);
    }

    @Override
    public String convertToDatabaseValue(List<TagObj> entityProperty) {
        return TagObj.save(entityProperty);
    }
}
public final class ConvertUtils {

    public static <T> List<T> query(String databaseValue, Property<T> property, Class<T> c) {
        if (TextUtils.isEmpty(databaseValue)) {
            return null;
        } else {
            List<Long> ids = JSONUtils.parseArray(databaseValue, Long.class);

//            return App.instance()
//                    .getBox().boxFor(c)
//                    .get(ids);
            long[] id = new long[ids.size()];
            for (int i = 0; i < ids.size(); i++) {
                id[i] = ids.get(i);
            }
            return App.instance().getBox().boxFor(c)
                    .query()
                    .in(property, id)
                    .build().find();
        }
    }

}
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.assistant.one/com.assistant.one.ui.activity.AlarmActivity}: io.objectbox.exception.DbException: Could not begin read transaction (another read transaction is still active on this thread) (error code -30783)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6940)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
     Caused by: io.objectbox.exception.DbException: Could not begin read transaction (another read transaction is still active on this thread) (error code -30783)
        at io.objectbox.BoxStore.nativeBeginReadTx(Native Method)
        at io.objectbox.BoxStore.beginReadTx(BoxStore.java:371)
        at io.objectbox.BoxStore.callInReadTx(BoxStore.java:706)
        at io.objectbox.BoxStore.callInReadTxWithRetry(BoxStore.java:654)
        at io.objectbox.query.Query.callInReadTx(Query.java:273)
        at io.objectbox.query.Query.find(Query.java:193)
        at com.assistant.one.bean.db.ConvertUtils.query(ConvertUtils.java:35)
        at com.assistant.one.bean.db.TagConverter.convertToEntityProperty(TagConverter.java:19)
        at com.assistant.one.bean.db.TagConverter.convertToEntityProperty(TagConverter.java:15)
        at io.objectbox.Cursor.nativeGetEntity(Native Method)
        at io.objectbox.Cursor.get(Cursor.java:186)
        at io.objectbox.Box.get(Box.java:209)
        at com.assistant.one.ui.activity.AlarmActivity.initData(AlarmActivity.java:212)
        at com.assistant.one.ui.activity.AlarmActivity.onCreate(AlarmActivity.java:122)
        at android.app.Activity.performCreate(Activity.java:7174)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6940) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 
09-20 16:02:01.797 24723-24723/com.assistant.one E/CrashReport: # CRASH STACK: 
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.assistant.one/com.assistant.one.ui.activity.AlarmActivity}: io.objectbox.exception.DbException: Could not begin read transaction (another read transaction is still active on this thread) (error code -30783)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6940)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
     Caused by: io.objectbox.exception.DbException: Could not begin read transaction (another read transaction is still active on this thread) (error code -30783)
        at io.objectbox.BoxStore.nativeBeginReadTx(Native Method)
        at io.objectbox.BoxStore.beginReadTx(BoxStore.java:371)
        at io.objectbox.BoxStore.callInReadTx(BoxStore.java:706)
        at io.objectbox.BoxStore.callInReadTxWithRetry(BoxStore.java:654)
        at io.objectbox.query.Query.callInReadTx(Query.java:273)
        at io.objectbox.query.Query.find(Query.java:193)
        at com.assistant.one.bean.db.ConvertUtils.query(ConvertUtils.java:35)
        at com.assistant.one.bean.db.TagConverter.convertToEntityProperty(TagConverter.java:19)
        at com.assistant.one.bean.db.TagConverter.convertToEntityProperty(TagConverter.java:15)
        at io.objectbox.Cursor.nativeGetEntity(Native Method)
        at io.objectbox.Cursor.get(Cursor.java:186)
        at io.objectbox.Box.get(Box.java:209)
        at com.assistant.one.ui.activity.AlarmActivity.initData(AlarmActivity.java:212)
        at com.assistant.one.ui.activity.AlarmActivity.onCreate(AlarmActivity.java:122)
        at android.app.Activity.performCreate(Activity.java:7174)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6940) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 
    #++++++++++++++++++++++++++++++++++++++++++#

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions