Could you please let me know on the below.
I have 15 database tables with corresponding java classes from which I need to pull data and show it to the REST client. We are using spring-jdbc without any ORM..
I am using BeanPropertyRowmapper to map the database values with the corresponding variables defined in java classes.
As a result there will be 15 Database hits..
I know its a bad practise and performance hit. could you suggest me..(only spring-jdbc i should use)
If you are able to a join, you can JDBC Template's query method to retrieve all the data in one shot. If your rows aren't one to one, that results in a lot of extra network usage (bandwidth though.) So you are trading data transfer for network connections. I wouldn't recommend this.
Do you need to get 15 tables each time? It seems likely some of these are static tables that you can get once and then cache.
I need to interact with all those 15 tables out of 19tables , I am already loading the other 4 tables which are static during the run time.
I can join some of the tables but the problem is that we need to map them to the nested classes.
I have wrote a custom mapper by extending the beanpropertyrowmapper. BUt not sure to what extent it could help me. I am going
to try that tomorrow.