• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

transform ResultSet data into a DTO

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Am trying to retrieve the following data from the database.


The table has "SupplierID, SupplierName, SiteId, SiteName" information.
For a given supplierID, there can be more than one siteID's.
The Query is
"SELECT DISTINCT supplier_id, supplier_name, site_division_id, site_division_name FROM spend ORDER BY supplier_id"
And there are some 5000 records.




Can any one suggest me the best way to populate these values in my DTO's?

Is it fine if I use a Map to store these retrieved values -
Map with Key having the supplierDTO(which has id & name attributes) and values being a *List* of SiteDTO(with id & name attributes)'s.
As one supplier can have more than one site, I'll be searching for the supplier in the Map before inserting.

Please suggest.

thanks,
Arnav
 
Marshal
Posts: 79974
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That suggestion would work, but I can't help thinking there is a way to write an SQL query which will do that work for you.
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic