Код: Выделить всё
@Entity
class User {
@Id
val id: UUID
@OneToOne
val info: UserInfo
@OneToMany
val documents: List
@OneToMany
val posts: List
}
Код: Выделить всё
interface UserRepository : JpaRepository {
@Query("custom query defined here")
fun findAllWithCustomQuery(): List
}
Код: Выделить всё
@Entity
@NamedEntityGraph(
name = "graph.User", // I referenced this name in the repository method
attributeNodes = [
NamedAttributeNode("userInfo")
]
)
class User {
@Id
val id: UUID
@OneToOne
val info: UserInfo
@OneToMany
val documents: List
@OneToMany
val posts: List
}
Код: Выделить всё
@Entity
@NamedEntityGraph(
name = "graph.User", // I referenced this name in the repository method
attributeNodes = [
NamedAttributeNode("userInfo"),
NamedAttributeNode("documents"),
NamedAttributeNode("posts")
]
)
class User {
@Id
val id: UUID
@OneToOne
val info: UserInfo
@OneToMany(fetch = FetchType.EAGER)
val documents: List
@OneToMany(fetch = FetchType.EAGER)
val posts: List
}
Есть ли способ получить всю необходимую мне информацию (несколько пользователей) и связанные с ними документы и сообщения) в одном запросе? Если нет, то есть ли способ предсказать, действительно ли декартово произведение будет проблемой или нет?
Подробнее здесь: https://stackoverflow.com/questions/792 ... many-relat