I'm trying to write a good (for me) naming strategy, but I'd like to use the name of the packages involved in the class, to make a table. For instance, the entity
com.example.project.entities.exampledata shoud make a table named
PROJ_ENTI_EXAMPLEDATA or something similar, from now it's just string manipulation.
The problem is that the NamingStrategy classes only get the unqualified class name to work with, so there is no way I con do it just configuring a custom NamingStrategy class.
I found that the only place to change would be in
org.hibernate.cfg.annotations.EntityBinder, line 353 (version 3.2.1.GA of hibernate-annotations), in function
getClassTableName, where
Code:
return mappings.getNamingStrategy().classToTableName( name );
can be changed to
Code:
return mappings.getNamingStrategy().classToTableName( annotatedClass.getName() );
to do the trick.
But that would be hacking the code, instead I just want to override the code in EntityBinder, and configure the server to use my custom binder.
Any idea about
how and
where to configure the binder???
Thank you for taking the time to read!
Saverio