{"action":"opened","issue":{"url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1429","repository_url":"https://api.github.com/repos/nhibernate/nhibernate-core","labels_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1429/labels{/name}","comments_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1429/comments","events_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1429/events","html_url":"https://github.com/nhibernate/nhibernate-core/issues/1429","id":271525459,"number":1429,"title":"SequenceStyleGenerator generates Ids twice on SQLite","user":{"login":"jrauber","id":10260156,"avatar_url":"https://avatars3.githubusercontent.com/u/10260156?v=4","gravatar_id":"","url":"https://api.github.com/users/jrauber","html_url":"https://github.com/jrauber","followers_url":"https://api.github.com/users/jrauber/followers","following_url":"https://api.github.com/users/jrauber/following{/other_user}","gists_url":"https://api.github.com/users/jrauber/gists{/gist_id}","starred_url":"https://api.github.com/users/jrauber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrauber/subscriptions","organizations_url":"https://api.github.com/users/jrauber/orgs","repos_url":"https://api.github.com/users/jrauber/repos","events_url":"https://api.github.com/users/jrauber/events{/privacy}","received_events_url":"https://api.github.com/users/jrauber/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-06T15:58:43Z","updated_at":"2017-11-06T15:58:43Z","closed_at":null,"author_association":"NONE","body":"The SequenceStyleGenerator produces identifiers which are not unique when the increment is happening inside a transaction that is rollbacked later on.\r\n\r\n- increment_size  - 2\r\n- initial_value - 1\r\n\r\nThe resulting sequence is \r\n\r\n- Id: 1 - [A001] - Commited\r\n- Id: 1 - [A001] - Commited\r\n- Id: 1 - [A001] - Commited\r\n\r\n\r\n```cs\r\n[Test]\r\npublic void SequenceStyleGeneratorGeneratesIdTwiceOnSQLiteWhenIncrementIsHappeningOnRollback()\r\n{\r\n\tvar generatedIds = new List<string>();\r\n\r\n\tusing (var session = OpenSession())\r\n\tusing (var transaction = session.BeginTransaction(IsolationLevel.ReadCommitted))\r\n\t{\r\n\t\tfor (int i = 1; i <= 2; i++)\r\n\t\t{\r\n\t\t\tvar entry = new Entity { Name = $\"A\" + i.ToString(\"000\") };\r\n\r\n\t\t\tsession.Save(entry);\r\n\r\n\t\t\tgeneratedIds.Add($\"Id: {entry.Id} - [{entry.Name}] - Commited\");\r\n\t\t}\r\n\r\n\t\ttransaction.Commit();\r\n\t}\r\n\r\n\tusing (var session = OpenSession())\r\n\tusing (var transaction = session.BeginTransaction(IsolationLevel.ReadCommitted))\r\n\t{\r\n\t\tvar entry = new Entity { Name = $\"B\" + 1.ToString(\"000\") };\r\n\r\n\t\tsession.Save(entry);\r\n\r\n\t\tgeneratedIds.Add($\"Id: {entry.Id} - [{entry.Name}] - Rollback\");\r\n\t\t\r\n\t\ttransaction.Rollback();\r\n\t}\r\n\r\n\tAssert.Throws<GenericADOException>(() => {\r\n\r\n\t\tfor (int i = 0; i < 5; i++)\r\n\t\t{\r\n\t\t\tusing (var session = OpenSession())\r\n\t\t\tusing (var transaction = session.BeginTransaction(IsolationLevel.ReadCommitted))\r\n\t\t\t{\r\n\t\t\t\tvar entry = new Entity { Name = $\"C\" + i.ToString(\"000\") };\r\n\r\n\t\t\t\tsession.Save(entry);\r\n\r\n\t\t\t\tgeneratedIds.Add($\"Id: {entry.Id} - [{entry.Name}] - Commited\");\r\n\r\n\t\t\t\ttransaction.Commit();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t});\r\n\r\n}"}}
{"actor":{"display_login":"jrauber"}}