That's because the deepCopy method is used, which is a convenient method that resets the behavior to default which therefore ignores what you initialized for the BeanPopulatable and DetailedBeanPopulatable parameters.
Try replicator.copy(pojo), instead of replicator.deepCopy(pojo) if you want to override the default behavior.
Note, however, that "vetoer" is applicable only if you are using HibernateBeanPopulatableSupport for the BeanPopulatable, which is the "default" behavior.
In general, only one of the three (ie vetoer, BeanPopulatable or DetailedBeanPopulatable) needs to be provided depending on how much control you want to have over the copying process, in increasing order of granularity.
Hope this helps.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your reply. I agree with the fact that only one of BeanPopulatable mus be used, it was just for test ;)
But what is the difference between "copy" and "deepCopy" ? between "copy" and "shallowCopy" ?
Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"deeCopy" copies the transitive closure of the entire object graph of the given object.
"shallowCopy" copies only the top level of the given object, bypass all the collection and map properties.
"copy" is the underlying implementation method used to support the different kinds of copying strategies. If it the most flexible but also the least convenient method to use.
Both "deepCopy" and "shallowCopy" are just convenient methods which are implemented on top of "copy".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am a little bean confused about BeanPopulatable usage for the HibernateBeanReplicator class.
Here is a snapshot of my test :
HibernateBeanReplicator replicator = new Hibernate3BeanReplicator();
replicator.initDetailedBeanPopulatable(new DetailedBeanPopulatable(){
public boolean shouldPopulate(...)
{ _log.info("DetailedBeanPopulatable"); return true; }
});
replicator.initBeanPopulatable(new BeanPopulatable(){
public boolean shouldPopulate(...)
{ _log.info("BeanPopulatable"); return true; }
});
replicator.initVetoer(new BeanPopulatable(){
public boolean shouldPopulate(...)
{ _log.info("Vetoer"); return true; }
});
return replicator.deepCopy(pojo);
When i run this code, my log only displays the "Vetoer" message.
Are the BeanPopulatable useless ?
The problem is that I need to use a DetailedBeanPopulatable to check if the Hibernate relation is lazy loaded or not (Hibernate.isInitialized)...
Regards
Bruno
>my log only displays the "Vetoer" message
That's because the deepCopy method is used, which is a convenient method that resets the behavior to default which therefore ignores what you initialized for the BeanPopulatable and DetailedBeanPopulatable parameters.
Try replicator.copy(pojo), instead of replicator.deepCopy(pojo) if you want to override the default behavior.
Note, however, that "vetoer" is applicable only if you are using HibernateBeanPopulatableSupport for the BeanPopulatable, which is the "default" behavior.
In general, only one of the three (ie vetoer, BeanPopulatable or DetailedBeanPopulatable) needs to be provided depending on how much control you want to have over the copying process, in increasing order of granularity.
Hope this helps.
Hi,
Thanks for your reply. I agree with the fact that only one of BeanPopulatable mus be used, it was just for test ;)
But what is the difference between "copy" and "deepCopy" ? between "copy" and "shallowCopy" ?
Regards
"deeCopy" copies the transitive closure of the entire object graph of the given object.
"shallowCopy" copies only the top level of the given object, bypass all the collection and map properties.
"copy" is the underlying implementation method used to support the different kinds of copying strategies. If it the most flexible but also the least convenient method to use.
Both "deepCopy" and "shallowCopy" are just convenient methods which are implemented on top of "copy".