0

There are three tables I am messing with in the database I created. I have an Item table, a subcategory table, and a Receipt_Item table.

The Item table has uni-directional link to the Subcategory. And the receipt_items table has a uni-direction link to the Item table.

Now the receipt_item table has a column of Item ID's. Due to my lack of knowledge with Hibernate SQL, I am unsure of what to do. I am trying to create a custom query that will give me a list of all items that have a given subcategory ID, and then those Item ID#'s need to have their rows pulled from the Receipt_Item table so that I can then pass that list to the service layer, and service layer grabs the price value that i am looking for and adds it together before sending the final total to the front end.

My question is, given a list of item ID's, how to do i get the database to grab all receipt_items rows where those Item ID#'s are a part of a list of ID's? I could do a for loop and have multiple queries go, and shove those results into a list and send that list to my service layer, however that seems highly inefficient.

Like i mentioned, i am planning on sending that list to my service layer, and then going through each object in the list, and summing their price column/data. How could i do that in Hibernate? Would it be more efficient for the database to handle that, or the service layer to handle that?

0 Answers0