Does anyone know if there is a framework out there that is able to strip out Hibernate collections from entity classes to make them serializable? I had a look at BeanLib but
Dozer works well for this. Simply map the bean instance to a copy of itself.
obj = dozerBeanMapper.map(obj, obj.getClass());
In mapping the instance to a new instance, Dozer ignores whatever specific runtime implementation is used for the collections and instead uses the standard implementations or whatever your classes default to.
I had a look at BeanLib but it only seems to do deep copies of entities while not allowing me to specify implementation mappings for the collection types in my entity classes.
I'm curious, why does it matter what implementation is used for your collection types? As a best practice it's best for your persistent classes to refer to List
, Set
, etc., the actual implementations shouldn't matter to anyone who consumes these classes - they just care about the data.