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));
}
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));
}
}