I have the following two tables:
Table name - Cake
-----------------------------
Id  | CakeType   |CakeState |
1   | Large      |Cooked    |
2   | Small      |Uncooked  |
----------------------------
Table name - Cake Feature
--------------------------------------------------
Id  | FeatureType    | FeatureValue       | CakeId|
1   | Flavour        | Chocolate          | 1     |
2   | Icing          | Whipped            | 1     |
3   | Maker          | John               | 1     |
4   | Flavour        | Orange             | 2     |
5   | Icing          | Cream Cheese       | 2     |
6   | Maker          | Mark               | 2     |
--------------------------------------------------
The queries on this table will be based on the following conditions:
- Get all the Cakes based on the input Flavour and Icing. Flavour and Icing will always be present in the input. So I'll need to perform a join on the above two tables and specify the FeatureType (which can be Flavour or Icing) and the FeatureValue.
 - The other conditions can be the CakeType and CakeState. But these conditions are optional, and a null pointer check will be required for them.
 
Can somebody help me in writing the JAVA/Hibernate function for this? I am trying to use CriteriaBuilder and Hibernate Joins<> for this, but am unable to construct a query. The output will be List