0

In our projects we are using entities from an inhouse library (we are using including them as a JAR). The class itself looks something like this (can't paste the real code here).

@Table(name = "X_MY_ENTITY")
public class MyEntity{
//columns...
}

In our persistence.xml we include a mapping file that maps the table names to our conventions.

  <entity class="com.example.MyEntity">
        <table name="REALNAME_MY_ENTITY"/>
        <sequence-generator name="id_seq" sequence-name="REALNAME_MY_ENTITY_SEQ" allocation-size="1"/>
    </entity>

Everything works fine.

Now we are using Arquillian for our integration tests and the sql-maven-plugin to generate our schema for the tests. Now I want the plugin to generate a view as well. In the sql-maven-plugin's configuration I include a sql file, where the view is created. This view uses the table mentioned above (eg. create or replace view EXAMPLE_VIEW as select * from REALNAME_MY_ENTITY). But when I try to build the project, I get an error: Table "REALNAME_MY_ENTITY" not found;

I got my orm.xml (the mapping-fie) in src/test/resources/META-INF/orm.xml, including it to my deployment-package and in my test-persistence.xml

We are using:

  • Java 8 + Java EE7
  • Open EJB v 7.0.4
  • Arquillian JUnit core 1.1.11.Final
  • sql-maven-plugin v1.5

How can I configure either Arquillian or the sql-maven-plugin that the mapped table names are used?

Patrick Zinner
  • 356
  • 4
  • 17
  • so the view works (sees the table) but the code is not able though it was previously working fine , right? are you sure that the schema name in the test environment is the same as it was working before ? – osama yaccoub Feb 19 '18 at 09:19
  • or you mean the arquillian is not able to read the orm.xml file ? did u try annotating the entity with @Table*name="REALNAME_MY_ENTITY") just to make sure where is the issue – osama yaccoub Feb 19 '18 at 09:20
  • I found it: I was looking at the wrong place. Apparently the schema was generated by the hibernate4-maven-plugin and you can configure a mapping file (hibernateMapping). Now the sql-maven-plugin generates the tables with the correct names. – Patrick Zinner Feb 19 '18 at 09:30

1 Answers1

0

I found it: I was looking at the wrong place. Apparently the schema was generated by the hibernate4-maven-plugin and you can configure a mapping file (hibernateMapping). Now the sql-maven-plugin generates the tables with the correct names.

Patrick Zinner
  • 356
  • 4
  • 17