@EntityGraph(attributePaths = ["enrollments"])
fun findByIdFetchingEnrollments(id: Long): Optional<Student>
Run Code Online (Sandbox Code Playgroud)
在我的存储库中,我只有一个基本存储库,其方法如下
fun findById(id: ID, vararg attributeNodes: String): Optional<T>
Run Code Online (Sandbox Code Playgroud)
这提供了很大的灵活性,因为我只能使用一种方法,例如,调用
studentRepository.findById(1L, "enrollments")
// or
studentRepository.findById(1L, "favouriteSubjects", "favouriteTeachers")
// and others...
Run Code Online (Sandbox Code Playgroud)
其中"enrollments"、"favouriteSubjects"、 和"favouriteTeachers"默认情况下是延迟获取实体字段,但有时需要急切地获取(以避免LazyInitializationException)
// Base repository interface. All my repositories will extend this interface
@NoRepositoryBean
interface Repository<T, ID> : JpaRepository<T, ID> {
fun findById(id: ID, vararg attributeNodes: String): Optional<T>
// other find methods
}
Run Code Online (Sandbox Code Playgroud)
// Custom base class. Inherits SimpleJpaRepository
class RepositoryImpl<T, ID>( …Run Code Online (Sandbox Code Playgroud) 我想加载位于当前工作文件夹子目录中的 lisp 脚本。相对路径是./crossover-operators/ER.lisp。
在 Linux 中,这是通过以下方式完成的:
(load "./crossover-operators/ER.lisp")
Run Code Online (Sandbox Code Playgroud)
在 Windows 中是通过以下方式完成的:
(load ".\\crossover-operators\\ER.lisp")
Run Code Online (Sandbox Code Playgroud)
如何创建一个独立于运行 Common Lisp 脚本的操作系统加载ER.lisp脚本的函数?