-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Using CGLib...
PostPosted: Fri Aug 06, 2004 9:23 am 
Beginner
Beginner

Joined: Tue Apr 06, 2004 6:13 pm
Posts: 39
Location: Pune, Maharashtra, INDIA
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.

_________________
thks
G1


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 9:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use Reflection and write a simple Helper class to do the copying.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.