I am trying to fetch a list from database and findAll() returns empty list. I have multiple jpa repositories but only one does not work. This is the code:
@Repository
public interface ProductCategoryRepository extends JpaRepository<ProductCategory,Integer> {
}
and this is the entity:
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProductCategory {
@Id
private Integer id;
private String name;
private String description;
@OneToMany(fetch = FetchType.EAGER,mappedBy = "productCategory", cascade = CascadeType.ALL)
@JsonIgnore
private List<Product> products = new ArrayList<>();
}
When I call productCategoryRepository.findAll() it returns empty list thus I have many entries in the database. Thanks for your help!
我遇到了同样的问题,我解决了生成 getter 和 setter 的问题,因为我没有配置我的 lombok
Can you please add @Column annotation to fields (except id) and try ? HOpe it will work.Do let me know if you still do not result.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.