Hi All,
I am working on a application which uses hibernate. I am using hibernatebeanreplicator to convert the proxy data from hibernate to null values. I want to just make few variables to null rather than making the whole class null. how can it be achieved.
I am providing an example here.
Class A {
B b;
}
class B {
int i; String s;
}
When i am fetching A it makes the object of B as null. I want to make just s of B to null as i need to use the i from class B.
Here is what i am using to convert the proxy data .
HibernateBeanReplicator replicator = new Hibernate3BeanReplicator() .initCustomTransformerFactory(conversionUtil.new Factory()); return replicator.copy(src); // return dest;
}
public class LazyHibernateCustomBeanTransformer implements
CustomBeanTransformerSpi {
public <T> boolean isTransformable(Object from, Class<T> toClass,
PropertyInfo propertyInfo) { // apply custom transformation for
// the uninitialized properties
return !Hibernate.isInitialized(from);
}
public <T> T transform(Object in, Class<T> toClass,
PropertyInfo propertyInfo) {
return null;
}
}
/** The factory for a {@link LazyHibernateCustomBeanTransformer}. */
public class Factory implements CustomBeanTransformerSpi.Factory {
public CustomBeanTransformerSpi newCustomBeanTransformer(
BeanTransformerSpi contextBeanTransformer) {
return new LazyHibernateCustomBeanTransformer();
}
}
Is there a method or way in beanlib to meet my requirement.
Thanks in advance,
Rima