@Test @Sql(scripts = {"/dropSequence.sql"}) public void shouldCreateSequenceAndGetNextValue() throws Exception { Serializable firstSequenceValue = dbSequenceGenerator.createAndGetNextSequence("SEQ_APPLICATION_NUMBER"); assertEquals(BigInteger.valueOf(1), firstSequenceValue); }
@Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) public Serializable createAndGetNextSequence(final String sequenceName) throws SQLException { Query query = entityManager.unwrap(Session.class).createSQLQuery("create sequence " + sequenceName); query.executeUpdate(); String NEXT_SEQ_SQL_QUERY = "SELECT nextval (:sequenceName) as nextval"; query = entityManager.unwrap(Session.class).createSQLQuery(NEXT_SEQ_SQL_QUERY); query.setParameter("sequenceName", sequenceName); return (Serializable) query.uniqueResult(); }
DBSequenceGenerator { @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) public Serializable createAndGetNextSequence(final String sequenceName) throws SQLException { Query query = entityManager.unwrap(Session.class).createSQLQuery("create sequence " + sequenceName); query.executeUpdate(); String NEXT_SEQ_SQL_QUERY = "SELECT nextval (:sequenceName) as nextval"; query = entityManager.unwrap(Session.class).createSQLQuery(NEXT_SEQ_SQL_QUERY); query.setParameter("sequenceName", sequenceName); return (Serializable) query.uniqueResult(); } }
DBSequenceGenerator { @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) public Serializable createAndGetNextSequence(final String sequenceName) throws SQLException { Query query = entityManager.unwrap(Session.class).createSQLQuery("create sequence " + sequenceName); query.executeUpdate(); String NEXT_SEQ_SQL_QUERY = "SELECT nextval (:sequenceName) as nextval"; query = entityManager.unwrap(Session.class).createSQLQuery(NEXT_SEQ_SQL_QUERY); query.setParameter("sequenceName", sequenceName); return (Serializable) query.uniqueResult(); }  }
DBSequenceGenerator { @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) public Serializable createAndGetNextSequence(final String sequenceName) throws SQLException { Query query = entityManager.unwrap(Session.class).createSQLQuery("create sequence " + sequenceName); query.executeUpdate(); String NEXT_SEQ_SQL_QUERY = "SELECT nextval (:sequenceName) as nextval"; query = entityManager.unwrap(Session.class).createSQLQuery(NEXT_SEQ_SQL_QUERY); query.setParameter("sequenceName", sequenceName); return (Serializable) query.uniqueResult(); }  @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) Serializable createAndGetNextSequence(final String sequenceName); }
DBSequenceGenerator { @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) public Serializable createAndGetNextSequence(final String sequenceName) throws SQLException { Query query = entityManager.unwrap(Session.class).createSQLQuery("create sequence " + sequenceName); query.executeUpdate(); String NEXT_SEQ_SQL_QUERY = "SELECT nextval (:sequenceName) as nextval"; query = entityManager.unwrap(Session.class).createSQLQuery(NEXT_SEQ_SQL_QUERY); query.setParameter("sequenceName", sequenceName); return (Serializable) query.uniqueResult(); }  @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) Serializable createAndGetNextSequence(final String sequenceName);  }