我的完整堆栈跟踪:
[ERROR] IllegalArgumentException in class: com.zpmc.ecs.domain.ExportReport, getter method of property: description - (BasicPropertyAccessor.java:194)
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.zpmc.ecs.domain.ExportReport.description
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:198)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValues(AbstractEntityTuplizer.java:482)
at org.hibernate.tuple.entity.PojoEntityTuplizer.getPropertyValues(PojoEntityTuplizer.java:241)
at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyValues(AbstractEntityPersister.java:3857)
at com.zpmc.ecs.autoexportbean.AutoExportListenerService.getAllTables(AutoExportListenerService.java:327)
at com.zpmc.ecs.autoexportbean.AutoExportListenerService.buildReport(AutoExportListenerService.java:154)
at com.zpmc.ecs.autoexportbean.AutoExportListenerService.getAutoExportExcel(AutoExportListenerService.java:130)
at com.zpmc.ecs.autoexportbean.MyTask.run(AutoExportListenerBean.java:137)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:172)
... 9 more
Pojo课程:
@Entity
@Table(name ="T_KPI_AUTO_EXPORT_CONFIG")
public class ExportReport implements Serializable {
private String description;
@Column(name ="Description", nullable = false)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
DAO类方法:
public List <String> getAllTables() throws SQLException {
Map<String, ClassMetadata> classMetaDataMap = hibernateTemplate.getSessionFactory().getAllClassMetadata();
for(Map.Entry<String, ClassMetadata> metaDataMap : classMetaDataMap.entrySet()) {
ClassMetadata classMetadata = metaDataMap.getValue();
AbstractEntityPersister abstractEntityPersister = (AbstractEntityPersister) classMetadata;
tableName = abstractEntityPersister.getTableName();
String[] propertyNames = abstractEntityPersister.getPropertyNames();
for(int i=0;i<propertyNames.length;i++){
Object[] propertyvalue =abstractEntityPersister.getPropertyValues(ExportReport.class,EntityMode.POJO);
System.out.println(propertyType+"Columns: " + propertyNames+"ddddd"+propertyvalue);
System.out.println(propertyNames[i]);
System.out.println(propertyvalue[i]);
}
}
}