[jboss-jira] [JBoss JIRA] (WFLY-6800) Database ignored in Postgres JDBC URL
Mickaël Vera (JIRA)
issues at jboss.org
Sun Jul 3 11:30:00 EDT 2016
Mickaël Vera created WFLY-6800:
----------------------------------
Summary: Database ignored in Postgres JDBC URL
Key: WFLY-6800
URL: https://issues.jboss.org/browse/WFLY-6800
Project: WildFly
Issue Type: Bug
Components: JPA / Hibernate
Affects Versions: 10.0.0.Final
Environment: java 8
windows 7
postgresql 9.4
Reporter: Mickaël Vera
Assignee: Scott Marlow
I created a data source like this
{code:xml}
<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>
{code}
{code:xml}
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>
{code}
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.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list