How to get the column name for an entity attribute using Hibernate

Hello, guys. Can someone help me. I want to create dynamic native sql builder. But i really can’t find, where hibernate holds db column names for attributes.
Thank you.

P.S. i use 5.2 hibernate. And solutions from other topic( https://stackoverflow.com/questions/46335682/how-to-get-column-names-of-jpa-entity ) don’t seem to work

Ok. i found.

((AbstractEntityPersister)((MetamodelImplementor) entityManager.getEntityManagerFactory().unwrap(
SessionFactory.class).getMetamodel()).entityPersister(Reference.class))
.getPropertyColumnNames(“viewName”)
1 Like

Check out this article as well.

1 Like