Patrick Zinner
Patrick Zinner

Reputation: 364

Overriding Table names for Arquillian Tests + sql-maven-plugin

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:

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

Upvotes: 0

Views: 45

Answers (1)

Patrick Zinner
Patrick Zinner

Reputation: 364

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.

Upvotes: 0

Related Questions