如何使用反射从Java Bean中检索自定义对象?

时间:2013-04-07 17:31:01

标签: java jpa reflection

我使用reflection重新审阅了Java Bean Properties。但是我无法从Orignal Bean获取集合,自定义对象。例如,

@Entity
@Table(name = "ucms_user_tbl")
public class Employee {

@Id
@Column(name="employee_no")
private int employeeno;
@Column(name="Employee_name")
private String employeeName,
//one-to-Many
@OneToMany(mappedBy="EmpDtl")
private List<EmpDtl> dtlList=new ArrayList<EmpDtl>();
@ManyToOne
@JoinColumn(name="status_id")
//Many-to-One
private EMPStatus empStatus;


}

我使用反射重新检查了雇员,但是我无法找到dtlList,empStatus属性。

for(Method metd:method){
    Annotation[] annotations = m.getAnnotations();
         for(Annotation annotation : annotations){          
                  if(annotation instanceof Column){
                Column myAnnotation = (Column) annotation;
                name=myAnnotation.name();

                   }
         }
}

0 个答案:

没有答案