ObjectBox: Efficiently remove orphaned entities left by dissolved ToOne relationObjectBox doesn't generate getters and constructors within entitiesInheritance in entities, using objectboxObjectBox: Get objects with specific relationsObjectbox: How to initialize ToMany<> relation in kotlin(ObjectBox) Gson doesn't parse from 'JSON to entity' which contains a ToOne relation objectKotlin and ObjectBox: Relations in Data ClassesObjectBox crash - java.lang.IllegalStateException ToOne object is nullObjectBox: Can an observable query detect changes to related entities?Inserting only unique values in objectbox entityObjectBox entities list in Android?
Everything Bob says is false. How does he get people to trust him?
What would be the benefits of having both a state and local currencies?
Star/Wye electrical connection math symbol
How to be diplomatic in refusing to write code that breaches the privacy of our users
Hide Select Output from T-SQL
Go Pregnant or Go Home
What is the oldest known work of fiction?
Do I need a multiple entry visa for a trip UK -> Sweden -> UK?
How to verify if g is a generator for p?
What is the term when two people sing in harmony, but they aren't singing the same notes?
How do I define a right arrow with bar in LaTeX?
Will it be accepted, if there is no ''Main Character" stereotype?
Where in the Bible does the greeting ("Dominus Vobiscum") used at Mass come from?
Mapping a list into a phase plot
Applicability of Single Responsibility Principle
What will be the benefits of Brexit?
Opposite of a diet
Why did Kant, Hegel, and Adorno leave some words and phrases in the Greek alphabet?
Is there a problem with hiding "forgot password" until it's needed?
Greatest common substring
What are the ramifications of creating a homebrew world without an Astral Plane?
Time travel short story where a man arrives in the late 19th century in a time machine and then sends the machine back into the past
Can a monster with multiattack use this ability if they are missing a limb?
Can I Retrieve Email Addresses from BCC?
ObjectBox: Efficiently remove orphaned entities left by dissolved ToOne relation
ObjectBox doesn't generate getters and constructors within entitiesInheritance in entities, using objectboxObjectBox: Get objects with specific relationsObjectbox: How to initialize ToMany<> relation in kotlin(ObjectBox) Gson doesn't parse from 'JSON to entity' which contains a ToOne relation objectKotlin and ObjectBox: Relations in Data ClassesObjectBox crash - java.lang.IllegalStateException ToOne object is nullObjectBox: Can an observable query detect changes to related entities?Inserting only unique values in objectbox entityObjectBox entities list in Android?
Let's assume the following data model for ObjectBox (I'm using ObjectBox 2.3.4):
@Entity
class SomeEntity
@Id var id: Long = 0
var otherEntityId: Long = 0
lateinit var otherEntity: ToOne<OtherEntity?>
@Entity
class OtherEntity
@Id var id: Long = 0
If I remove the owning entity SomeEntity
from its box, the OtherEntity
is basically orphaned. Is there a way to efficiently find and remove those orphaned instances of OtherEntity
?
I already thought about making the relation bi-directional by adding a ToOne<SomeEntity>
to OtherEntity
. The problem is that the relation isn't automatically managed during put so it's somewhat awkward to work with.
objectbox
add a comment |
Let's assume the following data model for ObjectBox (I'm using ObjectBox 2.3.4):
@Entity
class SomeEntity
@Id var id: Long = 0
var otherEntityId: Long = 0
lateinit var otherEntity: ToOne<OtherEntity?>
@Entity
class OtherEntity
@Id var id: Long = 0
If I remove the owning entity SomeEntity
from its box, the OtherEntity
is basically orphaned. Is there a way to efficiently find and remove those orphaned instances of OtherEntity
?
I already thought about making the relation bi-directional by adding a ToOne<SomeEntity>
to OtherEntity
. The problem is that the relation isn't automatically managed during put so it's somewhat awkward to work with.
objectbox
My first guess would be to check ifSomeEntity
has aotherEntity
and remove it before removingSomeEntity
? However, that won't work if multipleSomeEntity
can link to the sameOtherEntity
. In that case you could add a backlink ToMany toOtherEntity
. docs.objectbox.io/relations#one-to-many-1-n Though AFAIK there is no way to find OtherEntity where the ToMany is empty. I guess github.com/objectbox/objectbox-java/issues/677 could help with that.
– Uwe - ObjectBox
yesterday
add a comment |
Let's assume the following data model for ObjectBox (I'm using ObjectBox 2.3.4):
@Entity
class SomeEntity
@Id var id: Long = 0
var otherEntityId: Long = 0
lateinit var otherEntity: ToOne<OtherEntity?>
@Entity
class OtherEntity
@Id var id: Long = 0
If I remove the owning entity SomeEntity
from its box, the OtherEntity
is basically orphaned. Is there a way to efficiently find and remove those orphaned instances of OtherEntity
?
I already thought about making the relation bi-directional by adding a ToOne<SomeEntity>
to OtherEntity
. The problem is that the relation isn't automatically managed during put so it's somewhat awkward to work with.
objectbox
Let's assume the following data model for ObjectBox (I'm using ObjectBox 2.3.4):
@Entity
class SomeEntity
@Id var id: Long = 0
var otherEntityId: Long = 0
lateinit var otherEntity: ToOne<OtherEntity?>
@Entity
class OtherEntity
@Id var id: Long = 0
If I remove the owning entity SomeEntity
from its box, the OtherEntity
is basically orphaned. Is there a way to efficiently find and remove those orphaned instances of OtherEntity
?
I already thought about making the relation bi-directional by adding a ToOne<SomeEntity>
to OtherEntity
. The problem is that the relation isn't automatically managed during put so it's somewhat awkward to work with.
objectbox
objectbox
asked Mar 21 at 15:23
ahaaha
2,52112439
2,52112439
My first guess would be to check ifSomeEntity
has aotherEntity
and remove it before removingSomeEntity
? However, that won't work if multipleSomeEntity
can link to the sameOtherEntity
. In that case you could add a backlink ToMany toOtherEntity
. docs.objectbox.io/relations#one-to-many-1-n Though AFAIK there is no way to find OtherEntity where the ToMany is empty. I guess github.com/objectbox/objectbox-java/issues/677 could help with that.
– Uwe - ObjectBox
yesterday
add a comment |
My first guess would be to check ifSomeEntity
has aotherEntity
and remove it before removingSomeEntity
? However, that won't work if multipleSomeEntity
can link to the sameOtherEntity
. In that case you could add a backlink ToMany toOtherEntity
. docs.objectbox.io/relations#one-to-many-1-n Though AFAIK there is no way to find OtherEntity where the ToMany is empty. I guess github.com/objectbox/objectbox-java/issues/677 could help with that.
– Uwe - ObjectBox
yesterday
My first guess would be to check if
SomeEntity
has a otherEntity
and remove it before removing SomeEntity
? However, that won't work if multiple SomeEntity
can link to the same OtherEntity
. In that case you could add a backlink ToMany to OtherEntity
. docs.objectbox.io/relations#one-to-many-1-n Though AFAIK there is no way to find OtherEntity where the ToMany is empty. I guess github.com/objectbox/objectbox-java/issues/677 could help with that.– Uwe - ObjectBox
yesterday
My first guess would be to check if
SomeEntity
has a otherEntity
and remove it before removing SomeEntity
? However, that won't work if multiple SomeEntity
can link to the same OtherEntity
. In that case you could add a backlink ToMany to OtherEntity
. docs.objectbox.io/relations#one-to-many-1-n Though AFAIK there is no way to find OtherEntity where the ToMany is empty. I guess github.com/objectbox/objectbox-java/issues/677 could help with that.– Uwe - ObjectBox
yesterday
add a comment |
0
active
oldest
votes
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%2f55283840%2fobjectbox-efficiently-remove-orphaned-entities-left-by-dissolved-toone-relation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f55283840%2fobjectbox-efficiently-remove-orphaned-entities-left-by-dissolved-toone-relation%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
My first guess would be to check if
SomeEntity
has aotherEntity
and remove it before removingSomeEntity
? However, that won't work if multipleSomeEntity
can link to the sameOtherEntity
. In that case you could add a backlink ToMany toOtherEntity
. docs.objectbox.io/relations#one-to-many-1-n Though AFAIK there is no way to find OtherEntity where the ToMany is empty. I guess github.com/objectbox/objectbox-java/issues/677 could help with that.– Uwe - ObjectBox
yesterday