This content has been marked as final.
Show 2 replies
-
1. Re: how to get column name of table
tmalatinszki Sep 8, 2009 3:04 PM (in response to sathish0707)Hi,
Here's one way to get column names from an entity:
AbstractEntityPersister aep=((AbstractEntityPersister)session.getSessionFactory().getClassMetadata(ENTITYNAME.class)); String[] properties=aep.getPropertyNames(); for(int nameIndex=0;nameIndex!=properties.length;nameIndex++){ System.out.println("Property name: "+properties[nameIndex]); String[] columns=aep.getPropertyColumnNames(nameIndex); for(int columnIndex=0;columnIndex!=columns.length;columnIndex++){ System.out.println("Column name: "+columns[columnIndex]); } }
Just put Your entity class name instead ENTITYNAME, and You'll see all of your variables with the definied column names.
If You are using entityManager (em) instead hibernate session just replace session variable with (Session)em.getDelegate().
Let me know if it works fine.
Regards,
Tamas -
2. Re: how to get column name of table
sivalingam.sivasuthan Aug 6, 2011 5:58 AM (in response to sathish0707)Hi Tamas,
Thanks Tamas Its working fine and Solve my headache :)
Best Regards,
Siva