如何从父母那里取回孩子?假设我有父类和子类。我想从父母一方检索孩子的名单。这是我的家长班。+import ...@Entitypublic class Parent { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long id; @OneToMany(mappedBy="parent", cascade = CascadeType.REMOVE, orphanRemoval = true) private List<Child> Childs = new ArrayList<>(); private String name; * Getter and Setter are hide}这是我的父母孩子。+import ...@Entitypublic class Child { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long id; @ManyToOne() private Parent parent; private String childNote; * Getter and Setter are hide}这是我的存储库@Repositorypublic interface ParentRepository extends JpaRepository<Parent, Long> { @Query(value = "SELECT p.childs FROM Parent p where p.id =:id") List<Child> findxx(Long id);}这给了我一个错误:Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2019-03-05 00:59:16.281 ERROR 444 --- [ main] o.s.boot.SpringApplication : Application run failed
添加回答
举报
0/150
提交
取消