System.properties overide spy.properties

2004-07-08
2004-07-08
  • Hemal Pandya
    Hemal Pandya
    2004-07-08

    This is copy of my post in a hibernate forum...

    Our persistence layer is implemented using Hibernate; both MSSQL and Orace are supported. We often use P6Spy for debugging. Personally I find this to be a great combination. But to switch from one database to another two property files have to be modified: spy for driver name and hibernate for connection parameters.

    For my personal purposes I have modified hibernate and P6Spy as follows:
    1. In Hibernate (cfg.Configuration.addProperites actually) if the name of the property being set starts with "env." then strip the part set the property using System.setProperty.
    2. In P6Spy allow system properties that start with "p6spy." to overide the properties specified in spy.properties.
    Then I switch between different values of "env.p6spy.realdriver" and "hibernate.connection.driver_class" in hibernate.cfg.xml.

    Is this a bad idea? Is there a better alternative? Thanks in advance for your comments.