0
votes

After updating Objectbox from version 2.2 to 2.3.4 I got the following message when I build my app:

error: [ObjectBox] 'Athlete.shoesRelation' Only one @Backlink per relation allowed. Remove all but one @Backlink.

Code Athlete class:

@Transient @Expose
private List<Club> clubs;
@Transient @Expose
private List<Gear> bikes;
@Transient @Expose
private List<Gear> shoes;

@Backlink @Expose(deserialize = false, serialize = false)
public ToMany<Club> clubsRelation;
@Backlink @Expose(deserialize = false, serialize = false)
public ToMany<Gear> bikesRelation;
@Backlink @Expose(deserialize = false, serialize = false)
public ToMany<Gear> shoesRelation;

Code Gear class:

@Transient @Expose
private Athlete athlete;
@Expose(deserialize = false, serialize = false)
private ToOne<Athlete> athleteRelation;

Why can't I backlink the shoesRelation / what is going wrong?

1

1 Answers

1
votes

Your Athlete class has two backlinks to ToOne<Athlete> athleteRelation in Gear:

@Backlink
public ToMany<Gear> bikesRelation;
@Backlink
public ToMany<Gear> shoesRelation;

This was never supported, we added an explicit check for this in 2.3.0. https://github.com/objectbox/objectbox-java/issues/467

Either remove one of the ToMany, or add another ToOne, then explicitly name the ToOne relation the ToMany backlinks to:

@Backlink(to = "<TODO>")
public ToMany<Gear> bikesRelation;
@Backlink(to = "athleteRelation")
public ToMany<Gear> shoesRelation;