List<byte[]> listAsBytes= new ArrayList<byte[]>();
UUID randomId = UUID.randomUUID();
listAsBytes.add("Vivek".getBytes());
listAsBytes.add(new UUIDAccessor().toBytes(randomId));
result.setListAsBytes(listAsBytes);
em.merge(result); // merge with list as bytes.
em.clear(); // clear from cache.
result = em.find(EntityWithCollection.class, "entityId1");
Assert.assertNotNull(result);
assertOnList(result, randomId);
Set<byte[]> setAsBytes = new HashSet<byte[]>();
setAsBytes.add("Vivek".getBytes());
setAsBytes.add(new UUIDAccessor().toBytes(randomId));
result.setSetAsBytes(setAsBytes);
em.merge(result); // merge with list as bytes.
em.clear();
result = em.find(EntityWithCollection.class, "entityId1");