API 1.0.14 ExerciseDevice, ExerciseTypeDevice
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import org.hibernate.annotations.Fetch
|
||||
import org.hibernate.annotations.FetchMode
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class ExerciseDevice (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val deviceId: Long = 0,
|
||||
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var description: String = "",
|
||||
@get: NotBlank var imageUrl: String = ""
|
||||
){
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseDevice")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val translations: List<ExerciseDeviceTranslation> = mutableListOf<ExerciseDeviceTranslation>().toList()
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class ExerciseDeviceTranslation (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val translationId: Long = 0,
|
||||
|
||||
@get: NotBlank var languageCode: String?,
|
||||
@get: NotBlank var name: String = ""
|
||||
|
||||
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name = "deviceId", nullable = false)
|
||||
@JsonIgnore
|
||||
val exerciseDevice: ExerciseDevice? = null
|
||||
|
||||
}
|
||||
@@ -32,4 +32,8 @@ data class ExerciseType(
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val translations: List<ExerciseTypeTranslation> = mutableListOf<ExerciseTypeTranslation>()
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val exerciseDevices: List<ExerciseTypeDevice> = mutableListOf<ExerciseTypeDevice>()
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class ExerciseTypeDevice (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val exerciseTypeDeviceId: Long = 0,
|
||||
|
||||
@get: NotNull var exerciseDeviceId: Int?
|
||||
|
||||
) {
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name="exerciseTypeId", nullable=false)
|
||||
@JsonIgnore
|
||||
val exerciseType: ExerciseType? = null
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user