I have the following Entity classes
@io.objectbox.annotation.Entity
public class MultiplayerGameEntity extends BaseEntity {
private int durationInHours;
private ToMany<MultiplayerPlayerEntity> players;
public MultiplayerGameEntity() {
}
public int getDurationInHours() {
return durationInHours;
}
public void setDurationInHours(int durationInHours) {
this.durationInHours = durationInHours;
}
public ToMany<MultiplayerPlayerEntity> getPlayers() {
return players;
}
public void setPlayers(ToMany<MultiplayerPlayerEntity> players) {
this.players = players;
}
}
and
@io.objectbox.annotation.Entity
public class MultiplayerPlayerEntity extends BaseEntity {
public ToOne<UserEntity> userEntity;
public ToMany<MultiplayerRoundEntity> rounds;
public MultiplayerPlayerEntity() {
}
}
and finally
@io.objectbox.annotation.Entity
public class UserEntity extends BaseEntity {
private String uniqueId;
private String displayName;
private ToMany<UserEntity> friends;
public UserEntity() {
}
public UserEntity(String uniqueId, String displayName) {
this.uniqueId = uniqueId;
this.displayName = displayName;
}
public String getUniqueId() {
return uniqueId;
}
public void setUniqueId(String uniqueId) {
this.uniqueId = uniqueId;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public ToMany<UserEntity> getFriends() {
return friends;
}
public void setFriends(ToMany<UserEntity> friends) {
this.friends = friends;
}
}
I am trying to do a search and bring back all MultiplayerGameEntity that contain a given UserEntity
in SQL terms (as this is how my brain works) I'd be JOINing MultiplayerGameEntity to MultiplayerPlayerEntity and then MultiplayerPlayerEntity to UserEntity
I've tried to do this using link() but I can't seem to work out how to link the second relationship.
code so far...
queryBuilder.link(MultiplayerGameEntity_.players);
queryBuilder.link(MultiplayerPlayerEntity_.userEntity).equal(UserEntity_.uniqueId, uniqueId);
return queryBuilder.build().find();
}
but this doesn't work stating
java.lang.IllegalArgumentException: Relation not part of Entity MultiplayerPlayerEntity (17)
Is it even possible to do what I'm doing, or do I need to hack this somehow?