I try to run integration tests with Arquillian and Postgresql. I have this persistence.xml file which allow Hibernate to generate my database schema and pass all my tests:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/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">
<persistence-unit name="pu-it" transaction-type="JTA">
<jta-data-source>java:jboss/jdbc/testDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL95Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" />
<property name="hibernate.jdbc.time_zone" value="UTC" />
</properties>
</persistence-unit>
</persistence>
The problem is after testing, the OIDs previously injected in my scripts with lo_from_bytea(1, 'file') are still stored in my database and during the next start of my tests I will get this Hibernate error:
ERROR: duplicate key value violates unique constraint "pg_largeobject_metadata_oid_index"
D�tail�: Key (oid)=(1) already exists.
Is it possible to specify to Hibernate to destroy all OIDs like with the SELECT lo_unlink(1) query ?