Hi,
Even after my discussion with Christian on 'CGLib. How to use"
I feel I should try use CGLib in my application.(could not undersatand DTOAssembler what Christian suggested)
Could not find a forum to discuss it so using the misc section on hibernate forums.
If there is any better forum pls suggest.
I went thru CGlib source and found that net.sf.cglib.beans.BeanCopier() cud be used for what I want to achieve ----
For eg if My Hibernate POJO is like
Code:
public class Product extends Base implements Serializable {
private String description;
private String productCode;
private String salesPackageId;
private String productId;
private String institutionId;
....
and I have another UI object
Code:
public class ProductUI extends BaseUI {
private String _description;
private String _productCode;
private String _salesPackageId;
private String _productId;
private String _institutionId;
....
/*Note the
_ (underscore) prefix on the attributes.*/
with the getters and setters as appropriate.
I have many such similar objects (attribute types cud vary, be composite/arays/ collections/...)
In my business-object/ dao class,
I invoke Hibernate API to fetch data into the POJO and then have to write a private method to map each attribute into its corresponding attribute in the UI class.
I wish to cut down on the code for this 'mapping' part and it looks like BeanCopier() can be used.
But then how to handle the
_ (underscore) prefix on the attributes because of which the
POJO has a getProductCode() and setProductCode() while
UI has get_productCode() and set_productCode().
any clues will be appreciated.
or if there is anything better/ simpler than CGLib for this purpose pls suggest.