使用Entitry的最小版本的JPA规范



我如何在中创建一个enity的迷你版本以在jpa specification中使用。这可能吗。

Specification<Student> studentFinalSpecification = studentSpecification1
.and(studentSpecificaiton2);
StudentRepository.findAll(studentfinalSpecification );

相反,我想用几个假动作创建一个类似StudentMini的学生版学生必备。

Specification<StudentMini> studentMinifinalSpecification = studentSpecification1
.and(studentSpecificaiton2);
StudentFinalRepository.findAll(studentfinalSpecification );

如果学生和学校有关系,那么我想在studentMini中使用schoolMini关系。

是否可以在不为studentMini和schoolMini 创建表的情况下以这种方式创建

"可以,您可以将两个或多个实体映射到同一个数据库表。但是,只有在使用所有这些实体执行写操作或定义实体之间的关联时,才应该这样做。如果不是这样,您应该更好地使用DTO投影">

读取->

https://thorben-janssen.com/hibernate-tips-map-multiple-entities-same-table/

最新更新