Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8456613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:35:23+00:00 2026-06-10T12:35:23+00:00

My application uses sequences, and I’m trying to set up junit test environment with

  • 0

My application uses sequences, and I’m trying to set up junit test environment with HSQLDB in-mem database that would have a similar setup. This is how I’ve configured the sequences and their creation:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" lazy-init="true"
      destroy-method="close">
        <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
        <property name="url" value="jdbc:hsqldb:mem:test"/>
        <property name="username" value="sa" />
        <property name="password" value="" />
    </bean>
    <bean id="logSeqIncrementer" class="org.springframework.jdbc.support.incrementer.HsqlSequenceMaxValueIncrementer">
        <property name="dataSource" ref="dataSource" />
        <property name="incrementerName" value="public.agent_logs_seq" />
    </bean>

    <bean id="offerSeqIncrementer" class="org.springframework.jdbc.support.incrementer.HsqlSequenceMaxValueIncrementer">
        <property name="dataSource" ref="dataSource" />
        <property name="incrementerName" value="public.offers_seq" />
    </bean>
    <jdbc:embedded-database
        id="test"
        type="HSQL">
        <jdbc:script
            location="classpath:/create-ddl.sql" />
    </jdbc:embedded-database>   
</beans>

And contents of create-ddl.sql:

CREATE SEQUENCE public.agent_logs_seq;

Results in

java.sql.SQLException: Sequence already exists in statement

but if I comment that out, I get

java.lang.AssertionError: Unexpected exception:
org.springframework.dao.DataAccessResourceFailureException:
    Could not obtain sequence value; nested exception is
java.sql.SQLException: Sequence not found:
    AGENT_LOGS_SEQ in statement [call next value for public.agent_logs_seq]

The way I’m trying to use the sequence:

DataFieldMaxValueIncrementer incrementer =
    (DataFieldMaxValueIncrementer) context.getBean("logSeqIncrementer");
Integer logId = Integer.valueOf(incrementer.nextIntValue()); 

Edit: changed the details above so that correct sequence class would be used. It didn’t solve the issue, however.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:35:25+00:00Added an answer on June 10, 2026 at 12:35 pm

    I had a similar problem which is raised here.

    There were various solutions offered. The H2 Database seemed interesting. In the end I manually dropped and then create the sequences in a script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Spring application which uses Hibernate on a PostgreSQL database. I'm trying
I have a Rails 3.1 application that uses devise for authentication. I am trying
My application uses MS access database to save some sensitive information. Though that information
I have an application (C++) that I think would be well served by an
I am creating a C++ application the uses a MySQL database. I would like
Application uses Entity Framework 4.1 with database first approach. I have in database a
my asp.net application uses some sequences to generate tables primary keys. Db administrators have
I am working on a multithreaded application that uses DB2 for its primary database.
I have an application that uses xml config file, where I'm describing layouts for
I have one application which uses NHibernate to save entities to a database, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.