objectbox / objectbox/objectbox-java

Provide a way to force a refresh of the cached ToOne target

Offen
#1,002 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

enhancement
Vorherrschende Sprache
Java
Sterne
4.6k
Forks
311
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

When the target entity of a ToOne relationship is changed after it's resolved and cached, there is no way to force the target to refresh from the database.

Describe the solution you'd like
Provide a function that can be called that forces a new "get" from the box, caches the new entity, and returns it. This can be used when the app knows that the entity has been updated but wants those changes reflected in the related object.

Describe alternatives you've considered
As a workaround/alternative, the app can find the correct box, get an updated entity using the getTargetId(), then set the ToOne target entity to the updated entity. This works but requires a lot of extra code for something it feels like objectbox should be able to handle (especially since the ToOne relationship already knows the correct box for the get operation).

Additional context
Currently using this on Kotlin/Android.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die ToOne-Beziehungs-API zu finden und das Verhalten von getTargetId() sowie des target setter zu lesen. Implementiere die angeforderte Aktualisierungsoperation so, dass sie die zugehörige Entität aus ihrer bekannten Box abruft, den Cache aktualisiert und die Entität zurückgibt; fertig ist die Aufgabe, wenn Aufrufer ein geändertes Ziel aktualisieren können, ohne die Box manuell finden zu müssen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, java, kotlin
Bereich
databases, mobile-dev
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.