我有一个Product
表,它连接ProductCategory
表,@ManyToOne
和@OneToMany
关系。
Product
:
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "category_id")
@NotFound(action=NotFoundAction.IGNORE)
private ProductCategory productCategory;
Category
:
@OneToMany(fetch = FetchType.LAZY, mappedBy="productCategory" ,cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
@JsonBackReference
@OrderBy("id desc")
private Set<Product> products = new HashSet<Product>();
我有这个存储库方法从Product
表中检索数据:
@Query("SELECT p from Product p where cast(p.id as string) like :x or p.name like :x or p.description like :x or p.sku like :x or p.productCategory.name like :x")
public Page<Product> search(@Param("x") String keyword, Pageable pageable);
此方法不会返回其类别为null的产品。
即使我在productCategory
列上有空,也如何检索产品。
答案 0 :(得分:0)
我通过向查询添加expression <- "A + B"
example_fun <- function(new_var, expression) {
df %>%
mutate(!! new_var := !! parse_expr(expression))
}
example_fun(new_var, expression)
# A tibble: 10 x 3
# A B C
# <int> <int> <int>
# 1 1 1 2
# 2 2 2 4
# 3 3 3 6
# 4 4 4 8
# 5 5 5 10
# 6 6 6 12
# 7 7 7 14
# 8 8 8 16
# 9 9 9 18
#10 10 10 20
来解决了这个问题:
LEFT JOIN