Hibernate: dynamically set table name -
i have entity should dynamically persisted different tables according string property representing table name. hibernate's dynamic models looks want, cannot find how set table name :) can tell me i'm missing? thank's in advance.
p.s.another found solution http://java.dzone.com/articles/hibernate-dynamic-table-routin . dislike cause looks dirty hack. if i'll have multiple query parts named substring want replace.
if using jpa then
can @prepersist
.
if working plain hibernate
take @ event.
don't know if work you.
it looks namingstrategy
tutorial need.
@override public string classtotablename(string classname) { // code super.classtotablename() } org.hibernate.cfg.namingstrategy interface.
hibernate 3.6 has 4 implementations of interface:
org.hibernate.cfg.defaultcomponentsafenamingstrategy org.hibernate.cfg.defaultnamingstrategy org.hibernate.cfg.ejb3namingstrategy org.hibernate.cfg.improvednamingstrategy
implement code return table name.
Comments
Post a Comment