public int GetNext(string sequenceId, int startValue) { lock (syncRoot) { using (ISession session = database.OpenSession()) { int result = GetNext(session, sequenceId, startValue); session.Flush(); return(result); } } }