Missing sequences in HSQL for testing

I have an Oracle database where I have to use sequences for the primary key. All this works well, as I control the serial number. My problem is with my trials. Using Spring, I create an HSQL database and validate it. This database is built by viewing all of my objects. All of my entities, for the sake of working with Oracle, have the specified sequence name. The problem is that when I build DBQL db, it cannot find the sequence (which I expect) My tests pass, but in the end I get a lot of errors in the log. The journal is filled with such messages.

WARN JDBCExceptionReporter:233 - SQL Error: -5501, SQLState: 42501 ERROR JDBCExceptionReporter:234 - user lacks privilege or object not found: GENDERS_SEQ 

Does anyone know how I can remove these false errors? Can I make HSQL ignore sequences. Interestingly, in tests I can embed HSQL into the database, so it must use its own internal primary key generator.

Are there any ideas on how I can remove this crack from the log?

thanks

+7
source share
3 answers

I solved this by manually creating sequences as part of my test script. Not perfect, as I would prefer a Spring / HSQL combination. My code is:

 for (String sequence : sequences) { entityManager.createNativeQuery("DROP SEQUENCE " + sequence + " IF EXISTS").executeUpdate(); entityManager.createNativeQuery("CREATE SEQUENCE " + sequence + " as INTEGER").executeUpdate(); } 

where sequences is a list of strings that are the name of a sequence.

I used this @BeforeClass method for each test class. Not perfect, but it solves the problem.

+3
source

Try the H2 database instead; it has a feature called "Compatibility Modes" in which it behaves like Oracle or HSQL.

When choosing Oracle mode, you should be able to initialize the database with the same scripts (or Hibernate settings) that you use for your production.

+1
source

You can create your own in-memory-db through the script: how-to-initialize-in-memory-hsqldb-using-script-via-spring .

But I prefer to use arquillian to test data integration.

Disclosure: not working for arquillian.

-2
source

All Articles