Changed entities fetch from EAGER to disabled Lazy
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package eu.fosil.okupamicoche.entities
|
||||
|
||||
import org.hibernate.annotations.LazyCollection
|
||||
import org.hibernate.annotations.LazyCollectionOption
|
||||
import javax.persistence.*
|
||||
|
||||
typealias TravelId = Long
|
||||
@@ -8,8 +10,10 @@ typealias TravelId = Long
|
||||
class Travel(
|
||||
@Id @GeneratedValue var id: TravelId? = null,
|
||||
@ManyToOne
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
var driver: User,
|
||||
@ManyToMany(fetch = FetchType.EAGER) // https://stackoverflow.com/questions/22821695/how-to-fix-hibernate-lazyinitializationexception-failed-to-lazily-initialize-a
|
||||
@ManyToMany
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
var travelers: MutableList<User>,
|
||||
var departureDate: String,
|
||||
var origin: String,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package eu.fosil.okupamicoche.entities
|
||||
|
||||
import org.hibernate.annotations.LazyCollection
|
||||
import org.hibernate.annotations.LazyCollectionOption
|
||||
import javax.persistence.*
|
||||
|
||||
typealias UserId = String
|
||||
@@ -11,8 +13,9 @@ class User(
|
||||
var matrixId: String,
|
||||
var name: String,
|
||||
var email: String? = null,
|
||||
@OneToMany(mappedBy = "driver", fetch = FetchType.EAGER) // https://stackoverflow.com/questions/22821695/how-to-fix-hibernate-lazyinitializationexception-failed-to-lazily-initialize-a
|
||||
@OneToMany
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
var travelsAsDriver: List<Travel> = emptyList(),
|
||||
@ManyToMany(mappedBy = "travelers", fetch = FetchType.EAGER) // https://stackoverflow.com/questions/22821695/how-to-fix-hibernate-lazyinitializationexception-failed-to-lazily-initialize-a
|
||||
@ManyToMany@LazyCollection(LazyCollectionOption.FALSE)
|
||||
var travelsAsTraveler: List<Travel> = emptyList()
|
||||
)
|
||||
@@ -69,7 +69,6 @@ class PrivateTravelRestController(
|
||||
val userId = authService.currentUser(principal).id
|
||||
val useCase = ListUserTravels(travelRepository)
|
||||
val travels = useCase.listUserTravels(userId).map { t -> TravelDto(t) }
|
||||
logger.debug { "travels=$travels" }
|
||||
ListDto(useCase.countUserTravels(userId), travels)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ class AuthService(
|
||||
*/
|
||||
fun currentUser(principal: Principal): UserKeycloak {
|
||||
if (principal is JwtAuthenticationToken) {
|
||||
logger.debug { "claims=${principal.token.claims}" }
|
||||
return UserKeycloak(principal.token.claims)
|
||||
}
|
||||
throw UserIdNotFoundException()
|
||||
|
||||
Reference in New Issue
Block a user