Derby sequence loop in junit test

I'm having problems using Derby with the built-in driver (derby-10.9.1.0) and db in-memory in my JUNIT with Hibernate (hibernate-core-3.6.8.Final).

I use annotations and use hbm2ddl to create my db internal memory.

Everything works, except when I try to use a sequence.

The sequence is created (appears in the log), but when I try to add one entity (hibernate) using the PK associated with this sequence, my code starts an endless loop entry on each line:

Hibernate: values next value for app.SE_FERI 

My db is created as:

 jdbc:derby:memory:testdb;create=true 

I use hbm2ddl inside my code before using the database, for example:

 SchemaExport schemaExport = new SchemaExport(config); schemaExport.drop(true, true); schemaExport.create(true, true); 

Some help !?

+4
source share
1 answer

This problem occurs when the distribution parameter in the sequence is set to 1. Having set the value for me to> 1, I worked.

I know this thread is kind of old, but if anyone else has this problem, this might be the solution.

Edit: spelling

+1
source

Source: https://habr.com/ru/post/1440787/


All Articles