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: How to obtain setter method given column_name
PostPosted: Thu Sep 04, 2008 9:58 am 
Newbie

Joined: Thu Sep 04, 2008 9:46 am
Posts: 1
I am working with a legacy app. I have beans representing the tables. As part of an upload process, I am given a list of column_names and values for a set of rows for the table. Using reflection, I want to call the appropriate
setter for the bean given the column_name.

In browsing the Hibernate API, I cannot see how to obtain the setter (or getter) method given a column name:

Code:
@Entity
@Table("table_name")
public class Test
@Column(name="a_column")
private String theColumn;
public String getTheColumn() { return theColumn;}
public void setTheColumn(String s) {theColumn=s;}

...
So, given the string "a_column", how can I deterministically find the Property that defines the getter/setter methods, i.e., "setTheColumn" ??

The closest I could find was ColumnMetadata, but I cannot find how to go from column name to setter method.

TIA


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2008 11:01 am 
Newbie

Joined: Thu Jul 05, 2007 12:04 pm
Posts: 4
If you have the Configuration, can't you just iterate over all the mapped classes' attributes to figure this out?
Check out the Configuration class.
Traverse as Configuration.getClassMappings() -> ClassMapping.getPropertyIterator() -> Property.getColumnIterator() -> Column.getName().


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.