I am working on an application that requires a connection to two Postgres databases using sleep mode. Details are given below: -
Information about the software : - Java 1.6, Hibernate 4.1.0, Postgres 9.1.
Scenario problem . - The application needs to connect to the two TEDA and TEMET databases on my local host at run time and perform basic CRUD operations (for the initial phase).
We tried the approaches : - 1. Added a directory attribute to the <class> tag of the sleep mode mapping file. But that did not work . The directory was always selected as null. 2. Create two different data sources and session factories in my Hibernate context and use them in different DAO objects. This approach worked for me, and I was able to connect to various databases.
Problem statement and links : - I am looking for a way in which the directory approach mentioned in paragraph (1) can work.
I was looking for stack overflows and other forums like Connecting to multiple databases in sleep mode and what the "directory" is used in the hibernate annotated class , but most of them have discussed approach (2) that uses multiple data sources. I also looked at the hibernate service documentation in section 5.1.3, clause 6, which mentions that the directory attribute overrides the database name in db Url, but maybe I missed something.
Help. The properties file and hibernate mapping file that I changed are listed below.
Properties File -
driverClassName=org.postgresql.Driver urlDB=jdbc\:postgresql\://localhost\:5432/TEDA username=**** password=**** dialect=org.hibernate.dialect.PostgreSQLDialect
Hibernation mapping file
<hibernate-mapping> <class name="somepackage.PartnerPoc" catalog="TEMET" table="partner_poc"> </hibernate-mapping>
Please let me know if you need more information from my end.
Thanks in advance.
source share