2010-08-11 09:27 hibernate获得数据库的表名列名及其数据
@Test
public
void testHIbernateConfig1() {
SessionFactory factory=
new AnnotationConfiguration().configure().buildSessionFactory();
AbstractEntityPersister classMetadata = (SingleTableEntityPersister) factory.getClassMetadata("com.maple.domain.Ps");
String[] pns=classMetadata.getPropertyNames();
for(String s:pns)
{
String[] pcns=classMetadata.getPropertyColumnNames(s);
System.out.println("实体类的字段名:"+s+" 数据库中对应的属性名(列名):"+Arrays.toString(pcns));
}
}
标签:hibernate,String,pcns,数据库,factory,classMetadata,pns,类名
From: https://blog.51cto.com/u_16066377/6185099