Patel
JCHJava Community | Help. Code. Learn.
•Created by Patel on 6/24/2024 in #java-help
How to combine results from two table with same columns and return the result in Page
For example I've two tables Order1 and Order2 . Now I want to create one GET API name wih /getCombinedOrders which will return the result from Order1 and Order2 in page format.
Strategies I tried:
I've tried to get the data from Order1 repository and Order2 repository and return the result in Page. This strategy has some drawbacks regarding the Pagination. In this strategy if user pass pageSize 10 then we need to divide it into half and fetch 5 orders from each table combine and return but these is issue if one table has only 2 order left and another table still have 20 orders then our response will be only 7 orders.
2nd strategy will fetch all the data from both table, create list and sort and return but in this approach we negligent the use of Pagination that we do not need to fetch thousand of record for 10 rows on user screen.
Could you please help me on this?
4 replies
JCHJava Community | Help. Code. Learn.
•Created by Patel on 1/13/2024 in #java-help
Couldn't understand why 1<1 become true in following code?
I'm solving one of the basic recursion question from coding website. I need to assign 1 to n inside array, so platform will print the array.
Here is the link of question: https://www.codingninjas.com/studio/problems/print-1-to-n_628290?leftPanelTabValue=PROBLEM
Here is my solution for the platform:
And if you want to try in your IDE, you can try the following code:
Main.java:
13 replies