Skip to content

Instantly share code, notes, and snippets.

@michmzr
Created February 5, 2019 13:30
Show Gist options
  • Save michmzr/7dfc6c43f8e504335e28e3645bb9a2fc to your computer and use it in GitHub Desktop.
Save michmzr/7dfc6c43f8e504335e28e3645bb9a2fc to your computer and use it in GitHub Desktop.
Get Domain object table name by hibernate
def sessionFactory = Holders.applicationContext.getBean('sessionFactory')
ClassMetadata hibernateMetaClass = sessionFactory.getClassMetadata(User)
def mappedTable = hibernateMetaClass.getTableName()
print("User domain class is mapped to database table '$mappedTable')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment