-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to retrive all getters and setters in hibernate?
PostPosted: Fri Dec 26, 2008 3:05 am 
Newbie

Joined: Sat Oct 11, 2008 3:31 am
Posts: 11

How to retrive all getters and setters in hibernate just by providing class

name to it.

for eg.

suppose class Demo has three getter and setter methods

i want to retrive all getters in one aaray[]

(I think there is a method like

getGetters[] i m not sure how to use it)

Please help to retrive it


Thank you!!!




Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 28, 2008 11:51 pm 
Newbie

Joined: Tue Aug 29, 2006 2:54 am
Posts: 16
This is not the feature of Hibernate.
The question is about Java Reflection. The simple sample code as below
Code:
Class Demo = Demo .getClass();
Method[] methods = c.getDeclaredMethods();
....

You can get an array that contains all methods for the class.
You can even get the specified method if you know the method name.
Please refer the java api doc to find out the detail of Java Reflection.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2008 1:30 am 
Newbie

Joined: Sat Oct 11, 2008 3:31 am
Posts: 11
thanks for the reply......


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2008 6:52 pm 
Newbie

Joined: Tue Dec 30, 2008 6:20 pm
Posts: 4
Location: Bulgaria
You can also use the org.apache.commons.beanutils.PropertyUtils utility class:
Code:
PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(Demo .getClass());
descriptors[i].getReadMethod();
descriptors[i].getWriteMethod();

_________________
Nikolai Gagov


Top
 Profile  
 
 Post subject: thanks for the reply......
PostPosted: Wed Dec 31, 2008 1:13 am 
Newbie

Joined: Sat Oct 11, 2008 3:31 am
Posts: 11
thanks for the reply......


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.