How to set values for field after executing SQLQuery in Java Spring MVC

How to set values for field after executing SQLQuery in Java Spring MVC

I have this code

I have this code

query = session.createSQLQuery("select e.emp_id, emp_name, 
    emp_salary,address_line1, city, 
    zipcode from Employee e, Address a where a.emp_id=e.emp_id");
rows = query.list();

for(Object[] row : rows){ Employee emp = new Employee(); emp.setId(Long.parseLong(row[0].toString())); emp.setName(row[1].toString()); emp.setSalary(Double.parseDouble(row[2].toString())); Address address = new Address(); address.setAddressLine1(row[3].toString()); address.setCity(row[4].toString()); address.setZipcode(row[5].toString()); emp.setAddress(address); System.out.println(emp); }

I'm fetching datas from the query and setting it in the for each loop.But I want to set values now like this


I want to fetch data with column names.So that if there are 100 of columns in select statement I have to give 0-99 numbering in the row array. So if say, 46th column I don't want in select query then i have to change the numbering from 46-98. So is there any way to get it done with column names.

Note: Mapping is done through query not entity/pojo class.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Understand to Spring Boot: MySQL and JPA, Hibernate

Spring Boot uses Hibernate as the default JPA implementation. The property spring.jpa.hibernate.ddl-auto is used for database initialization. I've used the value “update” for this property.

Spring Boot Tutorials - Spring Boot Full Course

Spring Boot Tutorials | Full Course - What is Spring? Spring Boot is an open source Java-based framework used to create a Micro Service. Spring Boot contains a comprehensive infrastructure support for developing a micro service and enables you to develop enterprise-ready applications that you can “just run”.

How to use Spring Boot with Hibernate

A quick, practical intro to integrating Spring Boot and Hibernate/JPA.