Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partially Deserializing a complex java object

I have a java class hierarchy as follows.

public class Results{
    private String _query;
    private CachedRowSetImpl _resultSet;
    //... getter setters
}

I've serialized List<Results> resultList, consider this List contains 100 items and each _resultSet having more than 1000 records. I have 2 questions,

  1. When we deserialize this object, my application memory will hold the entire object and will it create heap size problem?
  2. If it will create resource problem, when I deserialize, can I ignore _resultSet being deserialized meaning just query is enough?

Correct me, if my understanding is wrong.

like image 787
Pasupathi Rajamanickam Avatar asked Aug 04 '26 04:08

Pasupathi Rajamanickam


1 Answers

If you implement Externalizable,your readExternal will look somewhat like :

     public void readExternal(ObjectInput in) throws IOException,  
         ClassNotFoundException {  
             _query=(String) in.readObject();  
            if(//yourCondition){
             _resultSet=(CachedRowSetImpl) in.readObject();  
            }
         }
like image 71
Sashi Kant Avatar answered Aug 06 '26 18:08

Sashi Kant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!