2016-07-11 27 views
0

Ich versuche, eine DDL in eine PostgreSQL 9.4-Datenbank beim Start von Wildfly 8.2.1 mit Hibernate 4.3.11 zu exportieren.hbm2ddl Schema-Export schlägt aufgrund von "Schema" fehl XYZ "nicht gefunden"

Die DDL wurde Hibernate-Maven-Plugin erstellt (http://juplo.de/hibernate-maven-plugin/) und sieht wie folgt aus:

alter table users_permissions 
    drop constraint if exists FK_eije6ps36awul7w1e8w9x0k0j; 

[more alter table...] 

drop table permissions cascade; 

[more drop table...] 

create table permissions (
    user_ID int8 not null, 
    permission varchar(64) not null, 
    primary key (user_ID) 
); 

[more create table...] 

alter table users 
    add constraint UK_ey6y24h3nkw1cvrryc9khsl5p unique (user_name, email); 

[more alter table...] 

create sequence hibernate_sequence; 

Das ist mein persistence.xml:

<?xml version="1.0" encoding="UTF-8" ?> 
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" 
     version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"> 
    <persistence-unit name="${persistence.unitName}" transaction-type="JTA"> 
     <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> 
     <class> 
    net.my-project.publisher.entity.UserEntity 
     </class> 
    <class> 
    net.my-project.publisher.entity.RoleEntity 
    </class> 
    <class> 
    net.my-project.publisher.entity.PermissionEntity 
    </class> 
    <properties> 
    <property name="hibernate.connection.driver_class" 
       value="org.postgresql.Driver"/> 
    <property name="hibernate.connection.url" 
       value="jdbc:postgresql://localhost:5432/my-project"/> 
    <property name="hibernate.connection.username" 
       value="${postgresql.login}"/> 
    <property name="hibernate.connection.password" 
       value="${postgresql.password}"/> 
    <property name="hibernate.default_schema" 
       value="${persistence.unitName}"/> 
    <property name="hibernate.dialect" 
       value="org.hibernate.dialect.PostgreSQL9Dialect"/> 
    <property name="hibernate.archive.autodetection" 
       value="class"/> 
    <property name="hibernate.hbm2ddl.auto" 
       value="create"/> 
    <property name="hibernate.max_fetch_depth" 
       value="3"/> 
    <property name="hibernate.show_sql" 
       value="true"/> 
    <property name="hibernate.format_sql" 
       value="true"/> 
    <property name="hibernate.order_updates" 
       value="true"/> 
    <property name="hibernate.generate_statistics" 
       value="true"/> 
    <property name="hibernate.use_sql_comments" 
       value="true"/> 
    <property name="hibernate.cache.use_query_cache" 
       value="true"/> 
    <property name="hibernate.cache.use_second_level_cache" 
       value="true"/> 
    <property name="hibernate.cache.provider_class" 
       value="org.hibernate.cache.EhCacheProvider"/> 
    <property name="hibernate.cache.region.factory_class" 
       value="org.hibernate.cache.EhCacheRegionFactory"/> 
    <property name="hibernate.cache.use_structured_entries" 
       value="true"/> 
    <property name="hibernate.transaction.auto_close_session" 
       value="false"/> 
    <property name="hibernate.connection.charSet" 
       value="UTF-8"/> 
    </properties> 

Jetzt , wenn die Bereitstellung auf dem WildFly-Server stattfindet, analysiert Hibernate meine persistence.xml und versucht, die DDL in meine PostgreSQL-Datenbank zu exportieren. Doch das scheitert:

[org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-10) JBAS010417: Started Driver service with driver-name = my-project.ear_org.postgresql.Driver_9_4 
[org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016008: Starting weld service for deployment my-project.ear 
[org.jboss.as.jpa] (ServerService Thread Pool -- 50) JBAS011409: Starting Persistence Unit (phase 2 of 2) Service 'my-project.ear/persistence-0.1-SNAPSHOT.jar#my-project' 
[org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 50) HCANN000001: Hibernate Commons Annotations {4.0.4.Final} 
[org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 50) HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect 
[org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000227: Running hbm2ddl schema export 
[stdout] (ServerService Thread Pool -- 50) Hibernate: 
[stdout] (ServerService Thread Pool -- 50)  alter table my-project.users_permissions 
[stdout] (ServerService Thread Pool -- 50)   drop constraint if exists FK_eije6ps36awul7w1e8w9x0k0j 
[org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: alter table my-project.users_permissions drop constraint if exists FK_eije6ps36awul7w1e8w9x0k0j 
[org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) Schema "MY-SCHEMA" not found; SQL statement: 

alter table my-schema.users_permissions 
    drop constraint if exists FK_eije6ps36awul7w1e8w9x0k0j [90079-173] 

Das Komische daran ist, dass ich erfolgreich über pgadmin3 auf mein PostgreSQL Server anmelden können Sie die Anmeldeinformationen in der persistence.xml gegeben werden. Außerdem kann ich auf ein Schema namens "my-schema" zugreifen.

Daher stimmt etwas mit der Konfiguration nicht. Warum kann Hibernate das Schema nicht finden?

Jede Hilfe wird sehr geschätzt. Walter

UPDATE: Sorry, es gibt einen Tippfehler in meinem ursprünglichen Post! Es ist nicht "my-project.users_permissions", sondern "my-schema.users_permissions".

Antwort

0

Sie können auf "my-schema" zugreifen, aber der Stack-Trace zeigt hier ein Schema namens "my-project" an. Ich würde nachsehen, ob es eines gibt.

[stdout] (ServerService Thread Pool -- 50) Hibernate: 
[stdout] (ServerService Thread Pool -- 50)  alter table my-project.users_permissions 
[stdout] (ServerService Thread Pool -- 50)   drop constraint if exists FK_eije6ps36awul7w1e8w9x0k0j 
[org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: alter table my-project.users_permissions drop constraint if exists FK_eije6ps36awul7w1e8w9x0k0j 
+0

Ähm, tut mir leid. Das ist mein Fehler. Das ist ein Tippfehler. Ich habe es überprüft. Hibernate sucht tatsächlich nach my-schema.users_permissions. – Walter