@Test @Sql(scripts = {"/dropSequence.sql", "/createSequence.sql"}) public void shouldGetNextSequenceNumber() throws Exception { Serializable firstSequenceValue = sequenceNumberGenerator.getNextSequence("SEQ_APPLICATION_NUMBER2017"); Serializable secondSequenceValue = sequenceNumberGenerator.getNextSequence("SEQ_APPLICATION_NUMBER2017"); assertEquals(BigInteger.valueOf(1), firstSequenceValue); assertEquals(BigInteger.valueOf(2), secondSequenceValue); }
@Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) public Serializable getNextSequence(final String sequenceName) throws SQLGrammarException { String NEXT_SEQ_SQL_QUERY = "SELECT nextval (:sequenceName) as nextval"; final Query query = entityManager.unwrap(Session.class).createSQLQuery(NEXT_SEQ_SQL_QUERY); query.setParameter("sequenceName", sequenceName); return (Serializable) query.uniqueResult(); }
SequenceNumberGenerator { @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) public Serializable getNextSequence(final String sequenceName) throws SQLGrammarException { String NEXT_SEQ_SQL_QUERY = "SELECT nextval (:sequenceName) as nextval"; final Query query = entityManager.unwrap(Session.class).createSQLQuery(NEXT_SEQ_SQL_QUERY); query.setParameter("sequenceName", sequenceName); return (Serializable) query.uniqueResult(); } }
SequenceNumberGenerator { @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) public Serializable getNextSequence(final String sequenceName) throws SQLGrammarException { String NEXT_SEQ_SQL_QUERY = "SELECT nextval (:sequenceName) as nextval"; final Query query = entityManager.unwrap(Session.class).createSQLQuery(NEXT_SEQ_SQL_QUERY); query.setParameter("sequenceName", sequenceName); return (Serializable) query.uniqueResult(); }  }
SequenceNumberGenerator { @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) public Serializable getNextSequence(final String sequenceName) throws SQLGrammarException { String NEXT_SEQ_SQL_QUERY = "SELECT nextval (:sequenceName) as nextval"; final Query 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 getNextSequence(final String sequenceName); }
SequenceNumberGenerator { @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = SQLGrammarException.class) public Serializable getNextSequence(final String sequenceName) throws SQLGrammarException { String NEXT_SEQ_SQL_QUERY = "SELECT nextval (:sequenceName) as nextval"; final Query 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 getNextSequence(final String sequenceName);  }