• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Inefficiency in queryForList(..) methods of JDBCTemplate

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do queryForList(..) methods in the JDBCTemplate class return a List with Maps where the Key=Column Name and Value=Column Value? As I understand it leads to a lot of repetition of column names in the maps. Basically all the Maps will have the same column names, what is the rationale behind returning so many Maps with similar Keys?

Any insight will be appreciated.

Regards,
Talib
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'd probably want to ask on a Spring list, but I'd imagine it's so each item in the list an be accessed in the same way, and it provides a "common-sense" way of accessing data.
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hm, I don't quite understand what you mean. Using a map is a way to store result data.
If we don't use map we could use domain object but that requires data mapping.
 
Talib Jockey
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So do you think it is a good idea to use this data structure in my application? I want to use something generic, do you see an issue with memory and efficiency because of the column names are repeated multiple times???

Regards,
Talib
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Map is generic enough, could you please to suggest something more generic?

Regarding inefficiency, the implementation could create only one String object and make many instances of Map refer to the same String object. So it's not inefficiency.
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Talib Jockey wrote:Why do queryForList(..) methods in the JDBCTemplate class return a List with Maps where the Key=Column Name and Value=Column Value? As I understand it leads to a lot of repetition of column names in the maps. Basically all the Maps will have the same column names, what is the rationale behind returning so many Maps with similar Keys?

Any insight will be appreciated.

Regards,
Talib





i feel it is the best because Programmer no need to bother on the order so i can get the value by passing the column name and when you iterate you need to concentrate on order of data accordingly you generated the query. more over you can get what ever the column data on without iteration.
can i know what is your prefered approch.

 
reply
    Bookmark Topic Watch Topic
  • New Topic