I want to know how to find column name from a property at runtime?
for example:
?<class name="com.aaa.Subject" table="TB_SUBJECT">
<id column="SJ_ID" name="id" type="long">
<generator class="assigned"/>
</id>
<property column="SJ_NAME" length="100" name="name" not-null="true" type="string"/>
</class>
public interface A {
public String getColumnName(Class bean,String propertyName);
}
public class B {
public void main(String[] d) {
A a = getA();//do not care how to get
System.out.println(a.getColumnName(Subject.class,"name"));
}
}
can you write a class implemented A that can get result as "SJ_NAME"?
|