0

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:

  1. 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.
  2. 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

Ivan
  • 8,508
  • 2
  • 19
  • 30
Dawson Smith
  • 473
  • 1
  • 6
  • 15
  • @Ivan can you help me out with this? – Dawson Smith May 03 '22 at 16:01
  • could you please add code you tried to the question? You can also try to search over Stackoverflow, possibly this can help you https://stackoverflow.com/questions/41982998/hibernate-criteriabuilder-to-join-multiple-tables. Bt again without seeing your code it is impossible to know what you already tried and what hasn't worked for you. – Ivan May 03 '22 at 17:44

0 Answers0