Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate - Getting the table name at runtime

 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic