-
Bug
-
Resolution: Duplicate
-
Major
-
None
-
10.0.0.Final
-
None
-
java 8
windows 7
postgresql 9.4
I created a data source like this
<datasource jndi-name="java:jboss/datasources/crawlRuntimeDS" pool-name="crawlRuntimePool" enabled="true" use-java-context="true"> <connection-url>jdbc:postgresql://localhost:5432/runtimedb</connection-url> <driver>postgresDD</driver> <security> <user-name>postgres</user-name> <password>postgres</password> </security> </datasource>
I reference it in a persistent unit: <persistence-unit name="crawl-runtime-pu"> <jta-data-source>java:jboss/datasources/crawlRuntimeDS</jta-data-source> <class>org.mvera.webscrap.model.crawl.runtime.CrawlEntity</class> <class>org.mvera.webscrap.model.crawl.runtime.PageCrawlStatusEntity</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="true" /> <property name="javax.persistence.schema-generation.database.action" value="none" /> <property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create" /> <property name="javax.persistence.schema-generation.scripts.create-target" value="D:/mvera/crawl-runtime-pu-create.sql" /> <property name="javax.persistence.schema-generation.scripts.drop-target" value="D:/mvera/crawl-runtime-pu-drop.sql" /> </properties> </persistence-unit>
I thought for a moment that all was working right. My data was persisted and I could read it from within an EJB using this datasource. But then I discovered that my data was not persisted at all in the database "crawlRuntimeDS" specified on the jdbc URL of the datasource but in the database "postgres" (a default database created during install of postgres).
This is a real problem as my application uses serveral databases (several persistence units). The workaround today is to put all entities in the same "postgres" database.
In the datasource, I can put any name as the database name, it is ignored, even if the database doesn't exist.