mercredi 6 avril 2016

how to add if else condtion inhibernate configuration file

I am working in spring hibernate project where I am connecting to multiple database. These database details are loaded in a properties file and is imported into hibernate.xml file. Each key was mapped as below.

dbName= dbHost

Mapping as below :

<bean id="dbId" parent="abstractDataSource">
        <property name="url" value="${dbName}" />
</bean> 

But now i need to include a condition such that the property key to be mapped to multiple values like below

E.g. dbName= statusFlag,dbHost,dbBackupHostName

I need to modify the hibernate configuration file such that using the keyName, corresponding values should be retrieved and splitted with comma separated. Then I need to check for the statusFlag. If it is true, then i should set the dbValue to 'dbHost', else if the flag is false, it should be set to 'dbBackupHostName'.

Please help me how to implement this condition check in hibernate configuration file.

Also please let me know if this approach is fine to proceed or am i making it too difficult to implement? Waiting for some valueable answers..

~~~Suriya

Aucun commentaire:

Enregistrer un commentaire