• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Hibernate - Getting the table name at runtime

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have recently written a custom primary key generator implementation. The implementation requires that you provide a context for a new key request. For example, if I want to get a new key for an insert into a table called Contacts, my context is Contacts. I would like for my key generator implementation to be able to determine at runtime what table the insert statement will go against. I want to use this table name as the context. Currently, I have clients configure the context as a parameter for my key generator implementation in the Hibernate mapping file. I would rather have my code get the table name and not require clients to configure it.

Does anyone know how to programatically get the table name from the Hibernate API if you start with a reference to either org.hibernate.engine.SessionImplementor or to the domain object that is to be peristed?
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic