Revision table 'REVINFO' not created
servaispe May 27, 2010 2:41 PMHi everybody,
I am testing Envers's features and there is a case where the revision table is not created. I am wondering if this is a bug or not.
I am using Hibernate 3.5.2 with the following working (partial) configuration :
[META-INF/persistence.xml]
<persistence version="2.0"
<persistence-unit name="party" transaction-type="RESOURCE_LOCAL">
...
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/MODEL?useUnicode=true&characterEncoding=UTF-8" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="" />
...
<property name="org.hibernate.envers.default_schema" value="AUDIT"/>
...
<!-- All EventListeners Are Defined -->
</persistence-unit>
[META-INF/orm.xml]
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<access>FIELD</access>
<entity class="com.company.model.Party">
<table name="PARTY" schema="MODEL" />
...
</entity>
...
</entity-mappings>
The PARTY table is created into the MODEL schema and the audit table PARTY_AUD is created into the AUDIT schema. But the REVINFO table is created into the MODEL schema... More over, if the connection URL is defined as follow, the REVINFO table is not even created :
jdbc:mysql://localhost?useUnicode=true&characterEncoding=UTF-8
As you can see, no schema is specified in this URL; which is legal (at least with mysql ) Anyway, to be able to see the REVINFO table created into the AUDIT schema, I had to specify the URL as follow :
jdbc:mysql://localhost/AUDIT?useUnicode=true&characterEncoding=UTF-8
And this is exactly why I had to specify the schema for the table element into the entity-mapping file...
So here is my question : is it a bug or I just don't use the Envers module very well ?
Please, note that I am a newbie using JPA/Hibernate/Envers trying to figure out how it works. Also : my next test with Envers and Hibernate is to define two persistence units; each one defined with a different schema and with at least one entity from the first unit referencing an entity from the other unit. Anyone know if this is a possible use case for these tools ?