Home > Enterprise >  Query MySQL database without having to create models Spring boot
Query MySQL database without having to create models Spring boot

Time:02-15

I am using Spring boot to create a web app. I need to store and query a list of patients however the table Patients has 30 Columns so it is too big to use a java model. I was wondering if there is a way where I can query ( using sql script ) my Patient table and then display the list on html

CodePudding user response:

I'm not sure what you mean by "big model".

I'd recommend using JdbcTemplate f you mean "I don't want all that JPA/Hibernate machinery". It's the lightest, simplest way to interact with relational databases using SQL.

You don't need a complex object model. Map each row into a Map of column name/value pairs and return a List of them for each query. Simple.

CodePudding user response:

I'm not expert but I think you need a model but you can simplified this model. You can add properties as you will use. Incoming SQL query response assign to your simple model. Also I think it's good that you want to simplify the model. It will be useful.

  • Related