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?













0















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.










share|improve this question






















  • 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
















0















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.










share|improve this question






















  • 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














0












0








0








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.










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 21 at 15:23









ahaaha

2,52112439




2,52112439












  • 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

















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













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
);



);













draft saved

draft discarded


















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















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%2f55283840%2fobjectbox-efficiently-remove-orphaned-entities-left-by-dissolved-toone-relation%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

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현