Hi,
I am using my domain model as a DTO. So there are instances where bean properties have private setters or there are no setters defined at all.
a. Hibernate can populate my model bean by accessing the fields directly. Is there a way get the Hibernate bean replicator to set bean properties directly using reflection or even access private setter methods?
b. Hibernate allows package protected constructors. Is there a way get the Hibernate bean replicator to construct such beans?
Regards,
Hari.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
a. Look for the classes ProtectedSetterMethodCollector and ProtectedReaderMethodFinder. There should be some examples of how they are used in the junit tests. You just need to do the equivalent classes for private methods. (There already exists PrivateSetterMethodCollector IIRC.)
b. IIRC it should just work.
Cheers.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
a. I used PrivateSetterMethodCollector and that takes care of my private setter copy. I guess I could always create private setters if beanlib does not support direct property access.
b. If I can now just as easily copy beans with empty package protected constructor ...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am using my domain model as a DTO. So there are instances where bean properties have private setters or there are no setters defined at all.
a. Hibernate can populate my model bean by accessing the fields directly. Is there a way get the Hibernate bean replicator to set bean properties directly using reflection or even access private setter methods?
b. Hibernate allows package protected constructors. Is there a way get the Hibernate bean replicator to construct such beans?
Regards,
Hari.
a. Look for the classes ProtectedSetterMethodCollector and ProtectedReaderMethodFinder. There should be some examples of how they are used in the junit tests. You just need to do the equivalent classes for private methods. (There already exists PrivateSetterMethodCollector IIRC.)
b. IIRC it should just work.
Cheers.
a. I used PrivateSetterMethodCollector and that takes care of my private setter copy. I guess I could always create private setters if beanlib does not support direct property access.
b. If I can now just as easily copy beans with empty package protected constructor ...