I have an application which operates on two separate database schemas in an Oracle database. On one of my deployment sites these schamas have different names than in my development environment, creating a need for me to dynamically reasign the schema names for all tables.
As long as I was using .hbm.xml files to declare my mappings I did this by creating my own SessionFactory, which overrode the postProcessConfiguration() method. This enabled me to get to the class mappings by calling Configuration.getClassMappings and change the schema for each mapping.
Now I've started to use annotations to declare my mappings, and this causes several problems.
Firstly, my custom SessionFactory must extend AnnotationSessionFactoryBean. This class has made the postProcessConfiguration() method final, so I can no longer override it. I've solved this by overriding the postProcessAnnotationConfiguration() method in stead.
But the really big problem is that Configuration.getClassMappings() no longer returns any mappings. I can see that there are annotatedClasses inside the AnnotationConfiguration object, but there is no "getAnnotatedClasses" method. So I can't access them.
My qestiong therefore is: How can I get to the annotated classes and change the schema for each entity?
|