• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

casting list of one class object into other class objects list

 
shreeni raikar
Greenhorn
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
 
Dawn Charangat
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic