I've got entity like this:
@Entity
@Table(name = "formula")
public class Formula {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(name = "formula_id")
private Long formulaId;
@Column(name = "name")
private String name;
@Column(name = "description")
private String description;
@Column(name = "time")
private int time;
@OneToMany(mappedBy = "formula",cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Product> productList = new ArrayList<>();
And another Entity:
@Entity
@Table(name = "products")
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long productId;
@Column(name = "product_name")
private String productName;
@Column(name = "amount")
private Double amount;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "formula_id")
private Formula formula;
I want to ask Query to DB which help me get every type of data (by key word). I've got all except List of <Product>. It look like this:
public interface FormulaRepository extends JpaRepository<Formula, Long> {
@Query("SELECT f FROM Formula f WHERE " + "CONCAT(f.name, f.description,
f.time)" + "LIKE %?1%")
List<Formula> findFormulaBy(String word);
How can add productList to Query and acomplished my searching? Is there any possibility to do this in findFormulaBy(String word); method?