1

I need to get column names from a table, I referred this link here: http://www.kodejava.org/examples/163.html

It shows using jdbc to get the metadata, I want to know is there any hibernate method similar to this? I am having mysql and oracle as the databases.

1
  • Hibernate needs you to hardcode the table and column names in order to map the entities. Why would you want to get them dynamically? Just hardcode them once more. Commented Jan 9, 2012 at 22:07

2 Answers 2

2

You can use the following codes:

String[] columnNames = sessionFactory.getClassMetadata(Java.class).getPropertyNames();

Type[] columnTypes = sessionFactory().getClassMetadata(Java.class).getPropertyTypes();
Sign up to request clarification or add additional context in comments.

Comments

0
String[] columnNames = getSessionFactory().getClassMetadata(Employee.class).getPropertyNames();

org.hibernate.type.Type[] columnTypes = getSessionFactory().getClassMetadata(Employee.class).getPropertyTypes();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.