diff --git a/src/main/kotlin/com/aitrainer/api/model/ExerciseTree.kt b/src/main/kotlin/com/aitrainer/api/model/ExerciseTree.kt index d9fc3b5..8684a71 100644 --- a/src/main/kotlin/com/aitrainer/api/model/ExerciseTree.kt +++ b/src/main/kotlin/com/aitrainer/api/model/ExerciseTree.kt @@ -1,5 +1,6 @@ package com.aitrainer.api.model +import com.fasterxml.jackson.annotation.JsonIgnore import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode import org.springframework.lang.NonNull @@ -15,9 +16,11 @@ data class ExerciseTree ( @get: NonNull var parentId: Int, @get: NotBlank var name: String = "", @get: NotBlank var imageUrl: String = "", - @get: NonNull var active: Boolean?, + @get: NonNull var active: Boolean? + +) { @OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseTree") @Fetch(value = FetchMode.SUBSELECT) val translations: List = mutableListOf().toList() -) \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/kotlin/com/aitrainer/api/model/ExerciseTreeTranslation.kt b/src/main/kotlin/com/aitrainer/api/model/ExerciseTreeTranslation.kt index 2a9c613..9759140 100644 --- a/src/main/kotlin/com/aitrainer/api/model/ExerciseTreeTranslation.kt +++ b/src/main/kotlin/com/aitrainer/api/model/ExerciseTreeTranslation.kt @@ -1,5 +1,6 @@ package com.aitrainer.api.model +import com.fasterxml.jackson.annotation.JsonIgnore import javax.persistence.* import javax.validation.constraints.NotBlank @@ -16,6 +17,7 @@ data class ExerciseTreeTranslation ( ) { @ManyToOne(fetch = FetchType.EAGER, optional = false) @JoinColumn(name = "treeId", nullable = false) + @JsonIgnore val exerciseTree: ExerciseTree? = null } diff --git a/src/main/kotlin/com/aitrainer/api/model/ExerciseType.kt b/src/main/kotlin/com/aitrainer/api/model/ExerciseType.kt index 42e7caa..86a8b1f 100644 --- a/src/main/kotlin/com/aitrainer/api/model/ExerciseType.kt +++ b/src/main/kotlin/com/aitrainer/api/model/ExerciseType.kt @@ -19,14 +19,16 @@ data class ExerciseType( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - val exerciseTypeId: Long = 0, + val exerciseTypeId: Long = 0 + + +) { + @OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType") + @Fetch(value = FetchMode.SUBSELECT) + val images: List = mutableListOf() @OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType") @Fetch(value = FetchMode.SUBSELECT) - val images: List = mutableListOf().toList(), + val translations: List = mutableListOf() - @OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType") - @Fetch(value = FetchMode.SUBSELECT) - val translations: List = mutableListOf().toList() - -) +} diff --git a/src/main/kotlin/com/aitrainer/api/model/ExerciseTypeImage.kt b/src/main/kotlin/com/aitrainer/api/model/ExerciseTypeImage.kt index eb23602..f33860a 100644 --- a/src/main/kotlin/com/aitrainer/api/model/ExerciseTypeImage.kt +++ b/src/main/kotlin/com/aitrainer/api/model/ExerciseTypeImage.kt @@ -1,5 +1,6 @@ package com.aitrainer.api.model +import com.fasterxml.jackson.annotation.JsonIgnore import org.springframework.lang.NonNull import javax.persistence.* import javax.validation.constraints.NotBlank @@ -19,6 +20,7 @@ data class ExerciseTypeImage ( @ManyToOne(fetch = FetchType.EAGER, optional = false) @JoinColumn(name="exerciseTypeId", nullable=false) + @JsonIgnore val exerciseType: ExerciseType? = null } diff --git a/src/main/kotlin/com/aitrainer/api/model/ExerciseTypeTranslation.kt b/src/main/kotlin/com/aitrainer/api/model/ExerciseTypeTranslation.kt index 7e32dfe..8825a09 100644 --- a/src/main/kotlin/com/aitrainer/api/model/ExerciseTypeTranslation.kt +++ b/src/main/kotlin/com/aitrainer/api/model/ExerciseTypeTranslation.kt @@ -1,5 +1,6 @@ package com.aitrainer.api.model +import com.fasterxml.jackson.annotation.JsonIgnore import org.springframework.lang.NonNull import javax.persistence.* import javax.validation.constraints.NotBlank @@ -18,5 +19,6 @@ data class ExerciseTypeTranslation ( @ManyToOne(fetch = FetchType.EAGER, optional = false) @JoinColumn(name = "exerciseTypeId", nullable = false) + @JsonIgnore val exerciseType: ExerciseType? = null }