【发布时间】:2019-02-18 03:31:22
【问题描述】:
@Entity
public class A{
//some properties
}
@Entity
public class B{
//Some properties
}
我想使用 JPA 从两个表中获取选定的列,我知道如何通过存储库和控制器获取单个实体表数据。
存储库:
public interface extends JPARepository<A, Long>{
List<A> findAll();}
控制器:
public class class_name{
@AutoWired
private JPARepository repo;
@RequestMapping("/data")
public List<A> getData(){
return repo.findAll();
}
}
以上代码是获取单表数据。现在,我想从两个表中获取选定的列。
Note: A, B Entities have mappings
【问题讨论】:
标签: spring hibernate rest spring-boot spring-data-jpa