API 1.0.15b CustomerExerciseDevice standalone

This commit is contained in:
Bossanyi Tibor
2020-11-23 21:18:16 +01:00
parent 3a70bcd10f
commit 11c9a6d112
7 changed files with 130 additions and 45 deletions
@@ -1,7 +1,5 @@
package com.aitrainer.api.model
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import javax.persistence.*
@Entity
@@ -20,7 +18,6 @@ data class Customer (
var trainerId: Long = 0,
var password: String? = "",
var birthYear:Int = 0,
// var weight: Int = 0,
var goal: String? = null,
var fitnessLevel: String = "beginner",
var bodyType: String? = null,
@@ -28,8 +25,4 @@ data class Customer (
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
var customerId: Long = 0
) {
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "customer")
@Fetch(value = FetchMode.SUBSELECT)
var exerciseDevices: List<CustomerExerciseDevice> = mutableListOf<CustomerExerciseDevice>()
}
)
@@ -12,14 +12,9 @@ data class CustomerExerciseDevice (
@GeneratedValue(strategy = GenerationType.IDENTITY)
val customerExerciseDeviceId: Long = 0,
@get: NotNull var exerciseDeviceId: Long?,
//@get: NotNull var customerId: Long?,
@get: NotNull var customerId: Long?,
@get: NotNull var favourite: Boolean?,
@get: NotNull var dateAdd: String? = null
) {
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "customerId", nullable = false)
@JsonIgnore
val customer: Customer? = null
}
)