Avatar of Nika Gudge
Nika GudgeFlag for United States of America

asked on 

how to add object to map?

I'm trying to add the records fetched from select query to a map.
Below is list implementation. it adds the employee object to the list :
      
      public List<Employee> getEmployee() throws Exception {
            String sql = "select * from Employee";
            List< Employee > emp = new ArrayList< Employee>();
            try {
                  emp  = (List< Employee >) jdbcTemplate.query(sql, new Object[]{}, new EmployeeMapper());
            } catch (Exception e)
            {
                throw new Exception("Exception occured while getting the emp ID :",e);
            }
            return emp;
      }

I need the map implementation which will store the primary key as the key and the remaining columns(object) as the value in the map.
for ex:
employee:
[Key]->empId  [Value]->[empNm    empCode     empAddr        empSal]
1                                         John          123                123 main st     4000
2                                        Doe            456                546 main st     6000
Map<String[empid], Object[employee]>
JavaOracle Database

Avatar of undefined
Last Comment
Nika Gudge
ASKER CERTIFIED SOLUTION
Avatar of dpearson
dpearson

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Nika Gudge
Nika Gudge
Flag of United States of America image

ASKER

worked
Java
Java

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo