# Serialization and deserialization of data members

**URL:** https://discuss.aerospike.com/t/serialization-and-deserialization-of-data-members/5239
**Category:** Data Types
**Tags:** query, java
**Created:** [June 11, 2018, 7:20pm UTC](https://discuss.aerospike.com/t/serialization-and-deserialization-of-data-members/5239 "2018-06-11T19:20:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Akash\_Singh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/akash_singh/32/1169_2.png) [@Akash\_Singh](https://discuss.aerospike.com/u/Akash_Singh)
#### Post date: [June 11, 2018, 7:20pm UTC](https://discuss.aerospike.com/t/serialization-and-deserialization-of-data-members/5239/1 "2018-06-11T19:20:29Z")

</div>

Hi All,

We are using 3.7.1 Aerospike Enterprise Edition for caching and getting below explained unexpected behavior.

Requirement : our requirement is to cache a list of child entries[client configuration] against a unique parent entity.

Our approach: Earlier we were inserting all config entries one by one with unique primary key for a particular entity.

For example:

```auto
parentEntity 1:
child entity:1_1
child entity:1_2
child entity:1_3
child entity:1_4
child entity:1_5

```

---------------java pseudocode----------------------------------------------------------------

```nohighlight
List<childEntity> pa;
If((pa = aerospikeOperation.query(class,index,entityId)!= null)
{
    return pa; //spring data aerospike;
}

else
{
    childList = service.getChilds(parentId);db query
}

for(child 1---5 :childList )
{
    client put{childId}
}

return childList;

```

* * *

But the problem we were facing with above approach was if a single entry insertion throws write timeout exception then next time we will get incomplete list [while querying from aerospike] as all above insertions were not atomic.

To Encounter above issue we created a wrapper and then we thought of inserting a complete parentWrapperObject that contains child lis at once.

---------------java pseudocode--------------

```java
ParentWrapper pa
if((pa = aerospikeOperation.query(entityId)!= null)
{
   return pa.getList();
}

else
{
    childList = service.getChilds(parentId);db query
}

ParentWrapper pa = new ParentWrapper();
pa.setChilds(childList)

client.put{pa}

return childList;

```

* * *

[in above approach we were assuming that it would serialize the whole list in a single bin and this operation would be atomic as the wrapper object insertion would be either successful or not]

But in above approach some child data members are getting changed to null even if the values were there when we were putting those values into Aerospike:

for example:

when inserting.

```auto
parent 1:
child 1 [name:"akash",url:"www.akash.com"] [java string]
child 2 [name:"alok",url:"www.alok.com"] [java string]

```

while pulling the data from Aerospike:

```auto
parent 1:
child 1 [name:"akash",url:null] [java string]
child 2 [name:"alok",url:nulll] [java string]

```

How is it possible??? and what is the resolution for this issue:

Thanks Akash

---

<div class="post-metadata">

### Author: ![Akash\_Singh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/akash_singh/32/1169_2.png) [@Akash\_Singh](https://discuss.aerospike.com/u/Akash_Singh)
#### Post date: [July 16, 2018, 10:47am UTC](https://discuss.aerospike.com/t/serialization-and-deserialization-of-data-members/5239/2 "2018-07-16T10:47:11Z")

</div>

Any Update?

---

<div class="post-metadata">

### Author: ![rbotzer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rbotzer/32/2114_2.png) [@rbotzer](https://discuss.aerospike.com/u/rbotzer)
#### Post date: [July 16, 2018, 1:10pm UTC](https://discuss.aerospike.com/t/serialization-and-deserialization-of-data-members/5239/3 "2018-07-16T13:10:17Z")

</div>

Try the same thing with a newer version of Aerospike that is actually supported, anything \>= 3.16. See if you can replicate it. If you can’t, move to that version, because you’re likely not going to get a bug fixed on an unsupported version fixed. Your Aerospike CE 3.7.1 is from 30 months ago.

Make sure you’re on a current version of the Java client, and use atomic [ListOperation](https://www.aerospike.com/apidocs/java/com/aerospike/client/cdt/ListOperation.html) methods where possible, instead of reading the entire list over to the application and manipulating it there, then saving it.
