JPA ManyToOne JsonIgnore
This commit is contained in:
parent
cec8f5a4a4
commit
62be53118b
@ -1,5 +1,6 @@
|
|||||||
package com.aitrainer.api.model
|
package com.aitrainer.api.model
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
import org.hibernate.annotations.Fetch
|
import org.hibernate.annotations.Fetch
|
||||||
import org.hibernate.annotations.FetchMode
|
import org.hibernate.annotations.FetchMode
|
||||||
import org.springframework.lang.NonNull
|
import org.springframework.lang.NonNull
|
||||||
@ -15,9 +16,11 @@ data class ExerciseTree (
|
|||||||
@get: NonNull var parentId: Int,
|
@get: NonNull var parentId: Int,
|
||||||
@get: NotBlank var name: String = "",
|
@get: NotBlank var name: String = "",
|
||||||
@get: NotBlank var imageUrl: 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")
|
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseTree")
|
||||||
@Fetch(value = FetchMode.SUBSELECT)
|
@Fetch(value = FetchMode.SUBSELECT)
|
||||||
val translations: List<ExerciseTreeTranslation> = mutableListOf<ExerciseTreeTranslation>().toList()
|
val translations: List<ExerciseTreeTranslation> = mutableListOf<ExerciseTreeTranslation>().toList()
|
||||||
)
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.aitrainer.api.model
|
package com.aitrainer.api.model
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
import javax.persistence.*
|
import javax.persistence.*
|
||||||
import javax.validation.constraints.NotBlank
|
import javax.validation.constraints.NotBlank
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ data class ExerciseTreeTranslation (
|
|||||||
) {
|
) {
|
||||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||||
@JoinColumn(name = "treeId", nullable = false)
|
@JoinColumn(name = "treeId", nullable = false)
|
||||||
|
@JsonIgnore
|
||||||
val exerciseTree: ExerciseTree? = null
|
val exerciseTree: ExerciseTree? = null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,16 @@ data class ExerciseType(
|
|||||||
|
|
||||||
|
|
||||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
@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<ExerciseTypeImage> = mutableListOf<ExerciseTypeImage>()
|
||||||
|
|
||||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
||||||
@Fetch(value = FetchMode.SUBSELECT)
|
@Fetch(value = FetchMode.SUBSELECT)
|
||||||
val images: List<ExerciseTypeImage> = mutableListOf<ExerciseTypeImage>().toList(),
|
val translations: List<ExerciseTypeTranslation> = mutableListOf<ExerciseTypeTranslation>()
|
||||||
|
|
||||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
}
|
||||||
@Fetch(value = FetchMode.SUBSELECT)
|
|
||||||
val translations: List<ExerciseTypeTranslation> = mutableListOf<ExerciseTypeTranslation>().toList()
|
|
||||||
|
|
||||||
)
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.aitrainer.api.model
|
package com.aitrainer.api.model
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
import org.springframework.lang.NonNull
|
import org.springframework.lang.NonNull
|
||||||
import javax.persistence.*
|
import javax.persistence.*
|
||||||
import javax.validation.constraints.NotBlank
|
import javax.validation.constraints.NotBlank
|
||||||
@ -19,6 +20,7 @@ data class ExerciseTypeImage (
|
|||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||||
@JoinColumn(name="exerciseTypeId", nullable=false)
|
@JoinColumn(name="exerciseTypeId", nullable=false)
|
||||||
|
@JsonIgnore
|
||||||
val exerciseType: ExerciseType? = null
|
val exerciseType: ExerciseType? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.aitrainer.api.model
|
package com.aitrainer.api.model
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
import org.springframework.lang.NonNull
|
import org.springframework.lang.NonNull
|
||||||
import javax.persistence.*
|
import javax.persistence.*
|
||||||
import javax.validation.constraints.NotBlank
|
import javax.validation.constraints.NotBlank
|
||||||
@ -18,5 +19,6 @@ data class ExerciseTypeTranslation (
|
|||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||||
@JoinColumn(name = "exerciseTypeId", nullable = false)
|
@JoinColumn(name = "exerciseTypeId", nullable = false)
|
||||||
|
@JsonIgnore
|
||||||
val exerciseType: ExerciseType? = null
|
val exerciseType: ExerciseType? = null
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user