Skip to content

Commit

Permalink
Fixup relationship of Game to GameReviewsSummary (fixes #330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Aug 23, 2019
1 parent e663713 commit b55877f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/main/java/com/faforever/api/data/domain/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.yahoo.elide.annotation.Include;
import com.yahoo.elide.annotation.UpdatePermission;
import lombok.Setter;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Immutable;
import org.jetbrains.annotations.Nullable;

Expand All @@ -19,6 +20,7 @@
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.time.OffsetDateTime;
Expand Down Expand Up @@ -114,8 +116,10 @@ public List<GameReview> getReviews() {
return reviews;
}

@OneToOne(mappedBy = "game")
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
@UpdatePermission(expression = "Prefab.Role.All")
@BatchSize(size = 1000)
public GameReviewsSummary getReviewsSummary() {
return reviewsSummary;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

Expand Down Expand Up @@ -58,8 +56,7 @@ public float getLowerBound() {
return lowerBound;
}

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "game_id", insertable = false, updatable = false)
@OneToOne(mappedBy = "reviewsSummary")
@BatchSize(size = 1000)
public Game getGame() {
return game;
Expand Down

0 comments on commit b55877f

Please sign in to comment.