Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

casting list of one class object into other class objects list

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers.. shree here
i have been using using collection for displaying data in combo box. but when i put collection of class objects in session it takes too much of memory. insted i want to load a collection of data having only primary key & another field data in the new collection. (it can be done using iterator & other stuff , but it again takes lot of processing)
i am using hibernate criterea to get a collection.
is there any way so that i can get collection of class object with data in only required fields or casting it into new class with only two fields.
thank you all
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if this is a hibernate specific query, but copying the fields of a class in a list to another class, can be achieved using the BeanUtils class in apache-beanutils.jar. [So that you dont have to do the copying, identifying fields to copy etc, yourself.]

BeanUtils.copyProperties(Class1, Class2);

...will copy all the similar named fields in Class1 to Class2. Ofcourse, you will have to do the iteration yourself.

I know this might not be the exact answer you might be looking at, but possibly will invoke a thought on how it could be done more efficiently than your current situation
What's that smell? Hey, sniff this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic